1. List the user name of all logged-in users on the current system, note: The same user logged in multiple times, only once.
[email protected] ~]$ who | Cut-d '-f1 | Sort | Uniq
2. Remove the information about the user who last logged in to the current system.
[email protected] ~]$ who |TAIL-1
3. Remove the shell that is the user's default shell on the current system.
[Email protected] ~]$ cut-d:-f7/etc/passwd |uniq-c |sort-n |tail-1
4, the third field in the/etc/passwd the value of the largest 10 users of the information is changed to uppercase and saved to the/tmp/maxusers.txt file.
[Email protected] ~]$ 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.
[Email protected] yu]# ifconfig |grep inet |head-1
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.
[[email protected] ~]$ 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.
[Email protected] ~]$ ll-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.
[Email protected] ~]$ cat/etc/group |sort-t:-k3-n-r | Tail-10
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.
[Email protected] ~]$ 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, its GID is;
[Email protected] yu]# groupadd-g distro
(2), create user Mandriva, whose ID number is 1005; basic group is distro;
[Email protected] yu]# useradd-u 1005-g distro Mandriva
(3), create user Mageia, whose ID number is 1100, home directory is/home/linux;
[Email protected] yu]# useradd-u 1100-d/home/linux Mageia
(4), to the user mageia add password, password for mageedu;
[Email protected] yu]# passwd Mageia
(5), delete Mandriva, but retain their home directory;
[Email protected] yu]# Userdel Mandriva
(6), create user Slackware, its ID number is 2002, the basic group is distro, additional group Peguin;
[Email protected] yu]# Groupadd Peguin
[Email protected] yu]# useradd-u 2002-g distro-g Peguin Slackware
(7), modify the Slackware default shell for/BIN/TCSH;
[Email protected] yu]# usermod-s/bin/tcsh Slackware
(8), add additional Group admins for user Slackware;
[Email protected] yu]# groupadd Admins
[Email protected] yu]# 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;
[Email protected] yu]# passwd Slackware | 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;
[Email protected] yu]# Groupadd Nova
[Email protected] yu]# Groupadd clouds
[Email protected] yu]# useradd-u 3003-g clouds-g Peguin,nova OpenStack
(11), add the system user MySQL, request its shell for/sbin/nologin;
[Email protected] yu]# useradd mysql-u 499-s/sbin/nologin
(12), use the echo command, non-interactive add a password for OpenStack.
[[email protected] yu]# echo "OpenStack" |passwd--stdin OpenStack
This article from "A Linux Tour" blog, declined reprint!
Linux third week job