1. List the user name of all logged-in users on the current system, note: The same user logged in multiple times, only once.
The commands for viewing system users are:
(1)getent passwd
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/88/76/wKiom1f4kbjTBzqNAAP2zD8UmS8424.png "title=" 409. PNG "alt=" Wkiom1f4kbjtbzqnaap2zd8ums8424.png "/>
View all user information on the system
(2) W
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/88/71/wKioL1f4iH2g3-N7AACuYaNJgTo878.png "title=" QQ picture 20161008134652.png "alt=" Wkiol1f4ih2g3-n7aacuyanjgto878.png "/>
View the process information that the logged-on user is using, and the information used by the command originates from the/var/run/utmp file
The information for the W command output includes:
-User Name
-User's machine name or TTY number
-Remote host Address
-time when the user logged on to the system
-Idle time (small function)
-time spent in a process attached to a TTY (terminal) (Jcpu time)
-time spent in the current process (pcpu time)
-commands that the user is currently using
The W command can also use the following option parameters:
-H Ignores header file information
-U Displays the load time of the result
-S does not show JCPU, PCPU, logon Hours
(3) who
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/88/71/wKioL1f4iSCzYD-tAABeXbII-Dk652.png "title=" 922. PNG "alt=" Wkiol1f4isczyd-taabexbii-dk652.png "/>
View (log in) the user name and the process that was started, the output is: User name, TTY number, time date, host address.
View user's user name with who value: Who | Cut-d '-f1
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/88/75/wKiom1f4iYSywTTIAAAz10haMBI328.png "title=" 29.png "alt=" Wkiom1f4iysywttiaaaz10hambi328.png "/>
The users command can be used to output the user name of the login
(4) WhoAmI
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/88/71/wKioL1f4ieDiwrlmAAAd0NnPa8E857.png "title=" QQ picture 20161008135306.png "alt=" Wkiol1f4iediwrlmaaad0nnpa8e857.png "/>
2. Remove information about the user who last logged in to the current system .
650) this.width=650; "title=" 1.png "src=" Http://s2.51cto.com/wyfs02/M01/88/70/wKioL1f4XUbAPz96AAAemZB1Apc226.png " alt= "Wkiol1f4xubapz96aaaemzb1apc226.png"/>
3. Remove the shell that is the user's default shell on the current system.
Command: cut-d:-f7/etc/passwd |uniq-c |sort-n |tail-1
650) this.width=650; "title=" 21.png "src=" http://s4.51cto.com/wyfs02/M01/88/70/wKioL1f4XZ2TK5rRAAAwzd2ylok530.png "alt=" Wkiol1f4xz2tk5rraaawzd2ylok530.png "/>
Uniq usage
Parameters
-C: Displays the number of occurrences of the row next to each column.
-D: Displays only the rows that appear repeatedly.
-F: Ignores the column specified by comparison.
-S: Ignores the comparison of the specified characters.
-U: Show only one row at a time.
-W: Specifies the character to compare.
-N: The first n fields are ignored along with the blanks in front of each field
+n: first n characters are ignored
Sort usage
Parameters
-B ignores whitespace characters that begin before each line.
-C checks whether the files are sorted in order.
-f sort, ignores uppercase and lowercase letters.
-M sorts the first 3 letters according to the abbreviation of the month.
-N Sorts by the size of the numbers.
-o< the output file > The sorted result into the specified file.
-R is sorted in reverse order.
-t< Delimited character > specifies the field separator character to use when sorting.
-K selects which interval to sort.
Tail usage
Parameters
Default to the end of the file, the last 10 lines are shown by default
The-n parameter can set the number of rows displayed,
The-f parameter is displayed automatically when the content of the file increases.
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.
650) this.width=650; "title=" 28.png "src=" http://s4.51cto.com/wyfs02/M02/88/74/wKiom1f4Xebz-EQKAADIRggGbz8398.png "alt=" Wkiom1f4xebz-eqkaadirgggbz8398.png "/>
Sort usage
The sort command helps us sort by different data types, and its syntax and common parameter formats
Parameters
-B ignores whitespace characters that begin before each line.
-C checks whether the files are sorted in order.
-f sort, ignores uppercase and lowercase letters.
-M sorts the first 3 letters according to the abbreviation of the month.
-N Sorts by the size of the numbers.
-o< the output file > The sorted result into the specified file.
-R is sorted in reverse order.
-t< Delimited character > specifies the field separator character to use when sorting.
-K selects which interval to sort.
TR usage
TR Conversion characters
5, take out the IP address of the current host, hint: The result of ifconfig command is sliced.
command: ifconfig | grep ' [0-9]{1,3}.[ 0-9]{1,3}. [0-9] {1,3}. [0-9] {1,3} ' |cut-d '-f10|head-n1
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/88/75/wKiom1f4i9PDGVk-AABK4agxAxg791.png "title=" 40124. PNG "alt=" Wkiom1f4i9pdgvk-aabk4agxaxg791.png "/>
Head usage
Show start to standard output, the default head command prints the first 10 lines of its corresponding file.
Parameters
-Q Hide file names
-V Show file name
-c< bytes > Display bytes
-n< rows > rows displayed
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.
Command: find/etc/-name "*.conf" | Tr ' A-Z ' A-Z ' >/tmp/etc.conf
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M00/88/71/wKioL1f4jH2DtVMXAAFxQecFPeY674.png-wh_500x0-wm_3 -wmp_4-s_195150577.png "title=" 24.png "alt=" Wkiol1f4jh2dtvmxaafxqecfpey674.png-wh_50 "/>
7. Displays the total number of sub-directories or files in the/var directory.
Command: Ll-a/var |wc-l
650) this.width=650; "title=" 37.png "src=" http://s4.51cto.com/wyfs02/M01/88/74/wKiom1f4X3PhOl7kAAAqa5suEX8647.png "alt=" Wkiom1f4x3phol7kaaaqa5suex8647.png "/>
8. Remove the names of the 10 groups with the smallest number of the third field in the/etc/group file.
Command: sort-t:-k3-n/etc/group | Cut-d:-f1 | Head
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/88/75/wKiom1f4jSCB-nehAABNvjL4OqE885.png "title=" QQ picture 20161008140708.png "alt=" Wkiom1f4jscb-nehaabnvjl4oqe885.png "/>
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.
Command: cat/etc/fstab/etc/issue >/tmp/etc.test
650) this.width=650; "title=" 430.png "src=" http://s4.51cto.com/wyfs02/M02/88/70/wKioL1f4X_ 7zdutvaabqwvrpkau936.png "alt=" Wkiol1f4x_7zdutvaabqwvrpkau936.png "/>
10. Summarize the methods used to describe the user and group management commands and complete the following exercises:
• User and Group management class commands:
Create User: Useradd
-U UID: defined in/etc/login.defs
-G GID: Indicates that the user belongs to the basic group, can be a group name, but also GID
-C "COMMENT": User's comment information
-d/path/to/home_dir: Home directory with the specified path
-S Shell: Indicates the user's default shell program, the available list in the/etc/shells file
-G Group, specify additional groups for the user, group must exist beforehand
-R Create System user, CentOS 6 is 0-499,centos 7 is 0-999
Delete User: Userdel
-r: Delete User home directory
Usermod: Modify User
-U uid: New UID
-G GID: New Basic Group
-G Group: New Add-on group
-S SHELL
-l:lock the specified user
Create Group: Groupadd
-G GID: Specify GID number
ID: View information about user-related IDs
passwd: Add change password, need root user rights
-L: Lock the specified user
-U: Unlock the specified user
-n:mindays: Specify the minimum period of use
-x:maxdays: Maximum use Period
-w:warndays: How many days in advance should I start warning
-i:inactivedays: Non-active period
-stdin: Receive user password from standard input
(1), create group distro, its GID is 2016;
Order Groupadd-g distro
650) this.width=650; "title=" 605.png "src=" http://s5.51cto.com/wyfs02/M01/88/70/wKioL1f4YGTz7zuuAAAQ_ 49-0r8076.png "alt=" Wkiol1f4ygtz7zuuaaaq_49-0r8076.png "/>
(2), create user Mandriva, whose ID number is 1005; basic group is distro;
Command Useradd-u 1005-g distro Mandriva
650) this.width=650; "title=" 5809.png "src=" http://s1.51cto.com/wyfs02/M00/88/74/ Wkiom1f4ynxjqylmaaaljhgf3is146.png "alt=" Wkiom1f4ynxjqylmaaaljhgf3is146.png "/>
(3), create user Mageia, whose ID number is 1100, home directory is/home/linux;
Command Useradd mageia-u 1100-s/home/linux
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/88/72/wKioL1f4jdnhKzx4AABQ74Ki-AU764.png "title=" 009. PNG "alt=" Wkiol1f4jdnhkzx4aabq74ki-au764.png "/>
(4), to the user mageia add password, password for mageedu;
echo "Mageedu" | passwd--stdin Mageia
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/88/75/wKiom1f4jiODibtyAABR7SJ2hpg823.png "title=" QQ picture 20161008141122.png "alt=" Wkiom1f4jiodibtyaabr7sj2hpg823.png "/>
(5), delete Mandriva, but retain their home directory;
Userdel Mandriva
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/88/72/wKioL1f4jmmTIJohAABEDxOgjLU119.png "title=" 230. PNG "alt=" Wkiol1f4jmmtijohaabedxogjlu119.png "/>
(6), create user Slackware, its ID number is 2002, the basic group is distro, additional group Peguin;
Useradd slackware-u 2002-g distro-g Peguin
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/88/72/wKioL1f4jw2y2TMrAABv7ZZZlys275.png "title=" 434. PNG "alt=" Wkiol1f4jw2y2tmraabv7zzzlys275.png "/>
(7), modify the Slackware default shell for/BIN/TCSH;
Usermod-s/bin/tcsh Slackware
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/88/76/wKiom1f4j0fwmHSTAABPE--eJ0I245.png "title=" 617. PNG "alt=" Wkiom1f4j0fwmhstaabpe--ej0i245.png "/>
(8), add additional Group admins for user Slackware;
Useradd-g Admins Slackware
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/88/72/wKioL1f4j6TTmqEEAACB7upR2mo770.png "title=" 1.png " alt= "Wkiol1f4j6ttmqeeaacb7upr2mo770.png"/>
(9), add password for Slackware, and require the minimum password age of 3 days, the maximum is 180 days, warning for 3 days;
Passwd-n 3-x 180-w 3 Slackware
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/88/76/wKiom1f4j86zJ-IOAACgClm_adk295.png-wh_500x0-wm_3 -wmp_4-s_3602228530.png "title=" 2.png "alt=" Wkiom1f4j86zj-ioaacgclm_adk295.png-wh_50 "/>
(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
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/88/76/wKiom1f4kALTFWAfAABR7SJ2hpg641.png "title=" 3.png " alt= "Wkiom1f4kaltfwafaabr7sj2hpg641.png"/>
(11), add the system user MySQL, request its shell for/sbin/nologin;
Useradd-s/sbin/nologin-r MySQL
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/88/76/wKiom1f4kEOi1zYGAABNCLwZPVg209.png "title=" 4.png " alt= "Wkiom1f4keoi1zygaabnclwzpvg209.png"/>
(12), use the echo command, non-interactive add a password for OpenStack.
echo "Tdl123" | passwd--stdin OpenStack
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/88/72/wKioL1f4kGrz36TQAABVeGA2bKk882.png "title=" 5.png " alt= "Wkiol1f4kgrz36tqaabvega2bkk882.png"/>
This article from the "11982172" blog, reproduced please contact the author!
Linux Fundamentals three