[root@localhost ~]# who |cut -d' ' -f1|sort|uniqcentosroot[root@localhost ~]# id `who |tail -1|cut -d' ' -f1`uid=0(root) gid=0(root) groups=0(root)[root@localhost ~]# cut -d':' -f7 /etc/passwd|sort|uniq -c|tr -s ' '|sort -n -t' ' -k2|tail -1|cut -d' ' -f3/sbin/nologin[root@localhost ~]# sort -n -t':' -k3 /etc/passwd|tail|tr 'a-z' 'A-Z' > /tmp/maxusers.txt[root@localhost ~]# ifconfig eth0|head -2|tail -1|tr -s ' '|cut -d':' -f2|cut -d ' ' -f1192.168.1.108[root@localhost ~]# find /etc -name "*.conf" -exec basename {} \; | tr 'a-z' 'A-Z' > /tmp/etc.conf[root@localhost ~]# find /var -maxdepth 1 | grep -v "^/var$" | wc -l17[root@localhost ~]# sort -n -t':' -k3 /etc/group|head|cut -d':' -f1rootbindaemonsysadmttydisklpmemkmem[root@localhost ~]# cat /etc/fstab /etc/issue > /tmp/etc.test[root@localhost ~]# groupadd -r -g 306 mysql[root@localhost ~]# tail -1 /etc/groupmysql:x:306:+ -n 修改组名
[root@localhost ~]# groupdel mysql[root@localhost ~]# ls -A /etc/skel.bash_logout .bash_profile .bashrc[root@localhost ~]# cat /etc/shells/bin/sh/bin/bash/sbin/nologin/usr/bin/sh/usr/bin/bash/usr/sbin/nologin[root@localhost ~]# groupadd -r -g 306 mysql[root@localhost ~]# useradd -r -g mysql -u 306 -M -s /sbin/nologin mysql[root@localhost ~]# id mysqluid=306(mysql) gid=306(mysql) groups=306(mysql)[root@localhost ~]# userdel -r mysqluserdel: mysql mail spool (/var/spool/mail/mysql) not founduserdel: mysql home directory (/home/mysql) not foundecho "hello" | passwd --stdin docker &> /dev/nullecho $?[root@localhost ~]# iduid=0(root) gid=0(root) groups=0(root)[root@localhost ~]# gpasswd -a mysql rootAdding user mysql to group root[root@localhost ~]# iduid=0(root) gid=0(root) groups=0(root)[root@localhost ~]# su - mysqlLast login: Sat May 19 22:14:58 CST 2018 on pts/0[mysql@localhost ~]$ iduid=1000(mysql) gid=1000(mysql) groups=1000(mysql),0(root)[mysql@localhost ~]$ lltotal 4-rw-rw-r-- 1 mysql mysql 5 May 19 22:15 a.txt-rw-rw-r-- 1 mysql mysql 0 May 19 22:15 b.txt[mysql@localhost ~]$ touch c.txt[mysql@localhost ~]$ lsa.txt b.txt c.txt[mysql@localhost ~]$ lltotal 4-rw-rw-r-- 1 mysql mysql 5 May 19 22:15 a.txt-rw-rw-r-- 1 mysql mysql 0 May 19 22:15 b.txt-rw-rw-r-- 1 mysql mysql 0 May 19 22:17 c.txt[mysql@localhost ~]$ newgrp root[mysql@localhost ~]$ iduid=1000(mysql) gid=0(root) groups=0(root),1000(mysql)[mysql@localhost ~]$ touch d.txt[mysql@localhost ~]$ lltotal 4-rw-rw-r-- 1 mysql mysql 5 May 19 22:15 a.txt-rw-rw-r-- 1 mysql mysql 0 May 19 22:15 b.txt-rw-rw-r-- 1 mysql mysql 0 May 19 22:17 c.txt-rw-r--r-- 1 mysql root 0 May 19 22:17 d.txt[root@localhost ~]# chage -l rootLast password change : neverPassword expires : neverPassword inactive : neverAccount expires : neverMinimum number of days between password change : 0Maximum number of days between password change : 99999Number of days of warning before password expires : 7[root@localhost ~]# iduid=0(root) gid=0(root) groups=0(root)[root@localhost ~]# id -u0[root@localhost ~]# id -g0[root@localhost ~]# id -G0[root@localhost ~]# su - mysql -c 'id'uid=1000(mysql) gid=1000(mysql) groups=1000(mysql)[root@localhost ~]# whoamiroot[root@localhost ~]# pwckuser 'ftp': directory '/var/ftp' does not existpwck: no changes[root@localhost ~]# grpck[root@localhost ~]# groupadd -g 2016 distro[root@localhost ~]# tail -1 /etc/groupdistro:x:2016:[root@localhost ~]# useradd -u 1005 -g distro mandirva[root@localhost ~]# tail -1 /etc/passwdmandirva:x:1005:2016::/home/mandirva:/bin/bash[root@localhost ~]# useradd -u 1100 -d /home/linux mageia[root@localhost ~]# tail -1 /etc/passwdmageia:x:1100:1100::/home/linux:/bin/bash[root@localhost ~]# echo "mageedu"|passwd --stdin mageiaChanging password for user mageia.passwd: all authentication tokens updated successfully.[root@localhost ~]# userdel mandirva[root@localhost ~]# ll -d /home/mandirva/drwx------ 2 1005 distro 62 May 28 18:54 /home/mandirva/[root@localhost ~]# groupadd peguin[root@localhost ~]# useradd -u 2002 -g distro -G peguin slackware[root@localhost ~]# tail -1 /etc/grouppeguin:x:2017:slackware[root@localhost ~]# tail -1 /etc/passwdslackware:x:2002:2016::/home/slackware:/bin/bash[root@localhost ~]# yum -y install tcsh[root@localhost ~]# cat /etc/shells/bin/sh/bin/bash/sbin/nologin/usr/bin/sh/usr/bin/bash/usr/sbin/nologin/bin/tcsh/bin/csh[root@localhost ~]# usermod -s /bin/tcsh slackware[root@localhost ~]# grep "slackware" /etc/passwdslackware:x:2002:2016::/home/slackware:/bin/tcsh“`
[root@localhost ~]# groupadd admins[root@localhost ~]# usermod -a -G admins slackware[root@localhost ~]# id slackwareuid=2002(slackware) gid=2016(distro) groups=2016(distro),2017(peguin),2018(admins)本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/99664


评论列表(1条)
很不错。命令建议格式化一下。