1. List the user name of all logged-in users on the current system, note: The same user logged in multiple times, only one time can be displayed
W.H.O. | Cut-d '-f1 | Sort-u
2. Remove information about the user who last logged in to the current system
Last | head-1 | Cut-d '-f1
3. Remove the shell that is the user's default shell on the current system.
cat/etc/passwd | Cut-d:-f7 | uniq-c | Sort-n | Tail-n 1
4, the third field in the/etc/passwd value of the largest 10 users of the information all changed to uppercase after saving the/tmp/maxuser.txt file
SORT-T:-k3-n passwd | Tail-n 10 | Tr ' A-Z ' A-Z ' >/tmp/maxuser.txt
5, remove the IP address of the current host, hint: The result of ifconfig command is sliced
Ifconfig | grep "inet\b" | Tr-s ' # ' | cut-d#-F3
6. List all the file names in the/etc directory with the. conf ending file and convert their names to uppercase and save them to the/tmp/etc.conf file
ls/etc/*.conf | Tr ' A-Z ' A-Z ' >/tmp/etc.conf
7. Display the total number of sub-directories or files in the/var/directory
ls/var/| Wc-l
8. The names of the 10 groups with the lowest value of the third field in the/etc/group file
Cat/etc/group | SORT-T:-k3-n | Head-n 10 | Cut-d:-f1
9. Remove the contents of the/etc/fstab and/etc/issue files to the same content to save to the/tmp/etc.test file
Cat/etc/{fstab,issue} >>/tmp/etc.test
10. Please summarize how to use the user and group management commands and complete the exercise
(1) Create group Distro with GID of 2016
Groupadd-g distro
(2) Create user Mandriva, whose ID number is 1005; basic group is distro;
Useradd-u 1005-g distro Mandriva
(3) Create the user Mageia, whose ID is 1100 and the home directory is/home/linux
Useradd-u 1100-d/home/linux Mageia
(4) Add password to user Mageia, password is magedu
echo "Magedu" | passwd--stdin Mageia
(5), delete Mandriva, but retain their home directory;
Userdel Mandriva
(6), create user Slackware, its ID number is 2002, the basic group is distro, additional group Peguin;
Useradd-u 2002-g distro-g Peguin Slackware
(7), modify the Slackware default shell for/BIN/TCSH;
Usermod-s/bin/tcsh Slackware
(8), add additional Group admins for user Slackware;
Groupadd Admins
Usermod-g Admins Slackware
(9), add password for Slackware, and require the minimum password age of 3 days, the maximum is 180 days, warning for 3 days;
echo "123" | Passwd-n 3-x 180-w 3--stdin Slackware
(10), add user OpenStack, whose ID number is 3003, the basic group is clouds, the additional group is Peguin and Nova;
Useradd-u 3003-g clouds-g Peguin,nova OpenStack
(11), add the system user MySQL, request its shell for/sbin/nologin;
Useradd-r mysql-s/sbin/nologin
(12), use the echo command, non-interactive add a password for OpenStack.
Echo 123 | passwd--stdin OpenStack
This article is from the "Linux" blog, so be sure to keep this source http://001230.blog.51cto.com/11559496/1887380
Homework Exercise: 3