1. List the user name of all logged-in users on the current system, note: The same user logged in multiple times, only once.
W.H.O. | Cut-d '-f1 | Sort-u
2. Remove the information about the user who last logged in to the current system.
Last | Head-1
3. Remove the shell that is the user's default shell on the current system.
cat/etc/passwd | Cut-d ': '-f7 |sort | uniq-c | Sort |head-1
4, the information of the third field in/ETC/PASSW D with the largest number of the first 10 users is changed to uppercase and then saved to the/tmp/maxusers.txt file.
Sort-t ': '-k3-n/etc/passwd |tail-10 |tr [A-z] [a-z] >/tmp/maxusers.txt
5, take out the IP address of the current host, hint: The result of ifconfig command is sliced.
Ifconfig | grep ' \<inet\> ' | head-1 | Cut-d ': '-f2 |tr-d ' bcast '
6 . List the file names of all files ending with. conf in/etc directory 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. Displays the total number of sub-directories or files in the/var directory.
Ls-a/var/| Wc-l
8. Remove the names of the 10 groups with the smallest number of the third field in the/etc/group file.
Sort-t ': '-k3-n/etc/group | head-10 | Cut-d ': '-f1
9, the contents of the/etc/fstab and/etc/issue files are merged into the same content and saved to the/tmp/etc.test file.
Cat/etc/{fstab,issue} >/tmp/etc.test
10. Summarize the methods used to describe the user and group management commands and complete the following exercises:
(1), create group distro, its GID is;
Groupadd-g distro
(2), create user Mandriva, whose ID number is 1005; basic group is distro;
Useradd-u 1005-g distro Mandriva
(3), create user Mageia, whose ID number is 1100, home directory is/home/linux;
Useradd-u 1100-d/home/linux Mageia
(4), to the user mageia add password, password for mageedu;
echo "Mageedu" | 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;
Usermod-a-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;
PASSWD-N3-X180-W3 Slackware & passwd 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-s/sbin/nologin-m MySQL
(12), use the echo command, non-interactive add a password for OpenStack.
echo "PASSWORD" | passwd--stdin OpenStack
Marco Linux jobs for the third week '