Content of this week's job:
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 | Sort |cut-d ""-f1 |uniq-c
2. Remove the information about the user who last logged in to the current system.
Last |head-n 1|cut-d ""-f1 |id
3. Remove the shell that is the user's default shell on the current system.
echo $SHELL; env |grep SHELL
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.
Sort-n-K 3-t ': '/etc/passwd |tail-n |tr A-z >/tmp/etc.conf
5, take out the IP address of the current host, hint: The result of ifconfig command is sliced.
Ifconfig eth0 |grep ' inet addr ' |awk ' {print $} ' |awk-f ': ' {print $} '
Show eth0 Nic inet addr field, remove both ends, and then remove ":" After a paragraph
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->/tmp/etc.conf
7. Displays the total number of sub-directories or files in the/var directory.
Du-c/var
8. Remove the value of the third field in the/etc/group file to the minimum of 1
Sort-n-K 3-t ': '/etc/group|head-n 10 | Cut-d ":"-f1
Sort by ': ' To arrange the first 10 rows and delete: After a paragraph of characters
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, its GID is 2016;
Groupadd-g distro
(2), create user Mandriva, whose ID number is 1005; basic group is distro;
Useradd-d-G Distro-u 1005 distro
(3), create user Mageia, whose ID number is 1100, home directory is/home/linux;
useradd-d/home/linux-u 1100 Megeia
(4), to the user mageia add password, password for mageedu;
Usermod-p mageedu 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-m-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-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-x 3-i 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 MySQL
(12), use the echo command, non-interactive add a password for OpenStack.
echo "123456" | passwd--stdin OpenStack
Linux Learning jobs-third week