1. List the user name of all logged-in users on the current system, note: The same user login multiple times, only one time can be displayed
W.H.O. | Cut-d '-f1 |sort |uniq
2. Lists information about the user who last logged on to the current system.
Last |head-1
3. List the shell that the user is the default shell on the current system.
Cut-d-F7/ETC/PASSWD | uniq-c | Sort-n | Tail-1
4, the third field in the/etc/passwd value of the largest 10 users of the information is changed to uppercase and saved to the/tmp/maxuser.txt file
SORT-T:-k3-n/etc/passwd | Tail | 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 ' [0-9]\{1,3\}\. [0-9]\{1,3\}\. [0-9]\{1,3\}\. [0-9]\{1,3\} '
Hostname-i
6. List all the file names in the/etc directory ending with. conf, and convert their names to uppercase and save them to the/tmp/etc.conf file.
find/etc/-name "*.conf" | Tr ' A-Z ' A-Z ' >/tmp/etc.conf
7. Displays the total number of sub-directories or files in the/var directory.
Ls-d/var/* | Wc-l
8. Remove the number of the third field in the/etc/group file with the lowest value of the 10 group name
SORT-T:-k3-n/etc/group | Cut-d:-f1 | Head
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/etc/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 with GID of 2016
Groupadd Distro-g 2016
(2) Create user Mandriva, whose ID number is 1005; basic group is distro;
Useradd mandriva-u 1005-g distro
(3) Create user Mageia, whose ID number is 1100, home directory is/home/linux;
Useradd mageia-u 1100-s/home/linux
(4) to the user Mageia add password, dense for Tangkai;
echo "Tangkai" | passwd--stdin Mageia
Usermod-p Tangkai Mageia
(5) Delete Mandriva, but keep its home directory;
Userdel Mandriva
(6) Create user Slackware, whose ID number is 2002, Basic Group is distro, additional group Peguin;
Useradd slackware-u 2002-g distro-g Peguin
(7) Modify the default shell of Slackware for/BIN/TCSH;
Usermod slackware-s/bin/tcsh
(8) Add additional Group admins for user Slackware;
Usermod Slackware-a-G admins
(9) To add a password for Slackware, and require the minimum password period of 3 days, the maximum is 180 days, warning for 3 days;
passwd slackware-n 3-x 180-w 3
(10) Add user OpenStack, whose ID number is 3003, the basic group is clouds, the additional group is Peguin and Nova;
Useradd openstack-u 3003-g clouds-g Penguin,nova
(11) Add the system user MySQL, request its shell for/sbin/nologin;
Useradd-r mysql-s/sbin/nologin
(12) using the Echo command, non-interactive add password for OpenStack;
echo Tangkai | passwd--stdin OpenStack
Linux Basics (3)