Lists the user names of all logged-in users on the current system, note that the same user logs on multiple times, only once
~]# who | Cut-d '-f1 | Sort | Uniq
Lists information about the last user logged on to the current system.
~]# Last | Head-1
Lists the shell on the current system that the user treats as their default shell.
~]# cut-d:-f7/etc/passwd | uniq-c | Sort-n | Tail-1
Change the value of the third field in/etc/passwd to the top 10 user with uppercase and save to the/tmp/maxuser.txt file
~]# sort-t:-k3-n/etc/passwd | Tail | Tr ' A-Z ' A-Z ' >/tmp/maxuser.txt
Lists the IP addresses of the current host, prompting: to slice the results of the ifconfig command.
~] #ifconfig | grep ' [0-9]\{1,3\}\. [0-9]\{1,3\}\. [0-9]\{1,3\}\. [0-9]\{1,3\} '
Lists all file names that end with. conf in the/etc directory and converts their names to uppercase and saved to the/tmp/etc.conf file.
~]# find/etc/-name "*.conf" | Tr ' A-Z ' A-Z ' >/tmp/etc.conf
Displays the total number of sub-directories or files in the/var directory.
~]# ls-d/var/* | Wc-l
Remove the name of the 10 group with the smallest number of the third field in the/etc/group file.
~]# sort-t:-k3-n/etc/group | Cut-d:-f1 | Head
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
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 mageedu;
~]# echo "Mageeu" | passwd--stdin 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-s/bin/tcsh Slackware
(8) Add additional Group admins for user Slackware;
~]# usermod-a-G admins Slackware
(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 OpenStack | passwd--stdin OpenStack
Some examples of Linux lookup filtering and user and group management commands