1, list the current system of all logged on user name, note: The same user log on multiple times, only show once.
[Root@node2 ~]# who
root pts/0 2016-10-08 13:28 (10.106.64.41)
root pts/1 2016-10-08 13:44 ( 10.106.64.41)
root pts/2 2016-10-08 14:22 (10.106.65.82)
root pts/3 2016-10-08 14:22 ( 10.106.65.82)
root pts/4 2016-10-08 15:26 (10.106.64.41)
root pts/5 2016-10-08 15:26 (10.106.64.41)
root pts/6 2016-10-08 15:26 (10.106.64.41)
[Root@node2 ~]# who-m
Root PTS/4 2016-10-08 15:26 (10.106.64.41)
2, remove the last login to the current system of the user information.
[Root@node2 ~]# last-1
root pts/6 10.106.64.41 Sat Oct 8 15:26
still logged in wtmp Begins Fri Aug 26 14:31:15 2016
3, remove the current system on the user as the default shell of the most of the shell
[Root@node2 ~]# cat/etc/passwd | Cut-d:-f7 | Sort | uniq-c | Sort-n | Tail
1/bin/sync
1/sbin/halt
1/sbin/shutdown
2/bin/bash
20/sbin/nologin
[Root@node2 ~]# cat/etc/passwd | Cut-d:-f7 | Sort | uniq-c | Sort-n | Tail-1
20/sbin/nologin
4, the third field in the/etc/passwd the largest number of the first 10 users of the information to save all uppercase to the/tmp/maxusers.txt file.
[Root@node2 ~]# cat/etc/passwd | Sort-nk 3-t: | Tail |tr ' [A-z] ' [A-z] ' >/tmp/maxusers.txt
[root@node2 ~]# [Root@node2 ~]# cat/tmp/maxusers.txt]
postfix:x : 89:89::/var/spool/postfix:/sbin/nologinnobody:x:99:99:nobody:/:/sbin/nologinavahi-autoipd:x:170:170:avahi Ipv4ll stack:/var/lib/avahi-autoipd:/sbin/nologinabrt:x:173:173::/etc/abrt:/sbin/nologinrabbitmq:x:995:993: RABBITMQ messaging Server:/var/lib/rabbitmq:/sbin/nologinepmd:x:996:994:erlang PORT MAPPER DAEMON:/TMP:/SBIN/ Nologinpolkitd:x:997:995:user for Polkitd:/:/sbin/nologinsystemd-network:x:998:996:systemd NETWORK MANAGEMENT:/:/ SBIN/NOLOGINSYSTEMD-BUS-PROXY:X:999:997:SYSTEMD Bus proxy:/:/sbin/nologinuser1:x:1000:1000::/home/user1:/bin/ Bash
5, remove the current host IP address, prompt: ifconfig command results.
[Root@node2 ~]# ifconfig ens160 | grep netmask | Cut-b 14-27
10.100.146.111
6, List all the files in the/etc directory with the end of. conf file name, and change it to uppercase and then save to the/tmp/etc.conf file.
[Root@node2 ~]# basename-a/etc/*.conf | TR ' [A-z] ' [A-z] ' >/tmp/etc.conf
[root@node2 ~]# cat/tmp/etc.conf
asound. CONF
DNSMASQ. CONF
Dracut. CONF
e2fsck. CONF
HOST. CONF
Kdump. CONF
KRB5. CONF
LD. So. CONF
lftp.conf
libaudit. CONF
Libuser. CONF
LOCALE. CONF
logrotate. CONF
man_db. CONF
mke2fs. CONF
Nsswitch. CONF
resolv. CONF
RSYNCD. CONF
RSYSLOG. CONF
Sestatus. CONF
SOS. CONF
SUDO. CONF
Sudo-ldap. CONF
sysctl. CONF
TCSD. CONF
UpdateDB. CONF
Vconsole. CONF
YUM. CONF
7. List the total number of subdirectories or files in the next level of the/var directory.
[Root@node2 ~]# ls-l/var/| Wc-l
21
8. Remove the name of the 10 group with the smallest value in the third field in the/etc/group file.
[Root@node2 ~]# Cat/etc/group | Sort-nk 3-t: | Head | Cut-d:-f1
root
bin
daemon
sys
ADM
TTY
Disk
LP
mem
Kmem
9. Merge the contents of the/etc/fstab and/etc/issue files into the same content and save them to the/tmp/etc.test file.
[Root@node2 ~]# cat/etc/fstab/etc/issue >/tmp/etc.test
[root@node2 ~]# cat/tmp/etc.test
# #/etc/fstab# Cre Ated by Anaconda on Fri Aug 14:12:50 2016## Accessible filesystems, by reference, are maintained under '/dev/disk ' # Mans pages Fstab (5), Findfs (8), mount (8) and/or Blkid (8) For more Info#/dev/mapper/centos-root/ xfs defaults
0 0/dev/mapper/centos-app/app xfs defaults 0 0uuid=b0abaaff-b81c-4a29-99ff-04d4df4d5c1b/boot XFS defaults 0 0/dev/mapper/centos-swap swap defaults 0 0\skernel \ r on a \m
10, please summarize the user and Group Management command of the use of the method and complete the following exercises:
1) Useradd: Create user
useradd [option] Login name-
u,--uid uid: Specify UID;
g,--gid Group: Specify base Group ID, this group must exist beforehand;
-G,--groups Group1[,group2,... [, GROUPN]]] : Indicates the additional group to which the user belongs, separated by commas between groups;-
C,--comment Comment: Indicates the annotation information;-
D,--home home_dir: The home directory of the user with the specified path; by copying/etc/ Skel This directory and rename the implementation; The specified home directory path will not replicate the environment configuration file for the user if it exists beforehand;-
s,--shell Shell: Specifies the user's default shell, and all available shell lists are stored in/etc/shells files; -
R,--system: creating system users;
2) Usermod: Modify user Properties
usermod [options] Login-
u,--uid uid: Modify the User ID The new UID specified for this place;-
G,--gid Group: Modify the basic group to which the user belongs;-
g ,--groups group1[,group2,... [, GROUPN]]] : Modifies the additional group to which the user belongs; The original additional group is overwritten;-a
,--append: Used with-G to append new additional groups to the user;-
C,--comment Comment: Modify the annotation information;
-D,--home Home_dir: Modify the user's home directory, the user's original file will not be moved to the new location;-
m,--move-home: can only be used with the-D option to move the original home directory to the new home directory;
-L,--login New_ LOGIN: Modify user name;-
S,--shell Shell: Modify user's default shell;-
L,--lock: Lock user password, i.e. add a "!" before the user's original password string. -
u,--unlock: Unlock user's password;
3) Userdel: Delete user-
r: Delete users delete their home directory;
4) passwd: Set User password
passwd [k] [l] [-u [-f]] [-d] [E] [-N mindays] [-X Maxdays] [-W warndays] [-I inactivedays] [-S] [- -stdin] [Username]
(1) passwd: Modify the user's own password
, (2) passwd Username: Modify the specified user's password, but only Root has this permission;
-L,-u: Lock and unlock user;
-D: Clears user password string;-
e Date: expiration, date;
-I: Inactive duration;-
n days: Minimum age of password;
x days: Maximum age of password;-
W Days: Warning period;
--stdin:
echo "PASSWORD" | passwd--stdin USERNAME
5) GPASSWD: Setting group password-a
USERNAME: adding users to a group-
D USERNAME: Removing users from a group
6) Groupadd: Create Group-
g: Specify GID
(1), create group distro, its GID is 2016;
[Root@node2 ~]# groupadd-g 2016 distro
(2), create user Mandriva, its ID is 1005; basic group is distro;
[Root@node2 ~]# useradd-g 2016-u 1005 Mandriva
(3), the creation user Mageia, its ID number is 1100, the home directory is/home/linux;
[Root@node2 ~]# useradd-u 1100-d/home/linux mageia
[root@node2 ~]# ID mageia
uid=1100 (Mageia) gid=1100 (Mageia) Group =1100 (Mageia)
(4), to the user mageia add password, password for mageedu;
[Root@node2 ~]# passwd mageia
Change the password for user Mageia.
New Password: invalid password:
password is less than 8 characters reenter
new password:
passwd: All authentication tokens have been updated successfully.
(5), delete Mandriva, but keep their home directory;
[Root@node2 ~]# Userdel Mandriva
[root@node2 ~]# ID mandrivaid
: mandriva:no Such user
[Root@node2 ~]# ls -d/home/mandriva/
/home/mandriva/
(6), the creation user Slackware, its ID number is 2002, the basic group is distro, the additional group is Peguin;
[Root@node2 ~]# groupadd Peguin [root@node2 ~]# useradd-u 2002-g distro-g peguin slackwar e[root@node2 ~]#
ID s Lackware
uid=2002 (slackware) gid=2016 distro (=2016), distro (2017)
(7), modify the default shell of Slackware for/BIN/TCSH;
[Root@node2 ~]# usermod-s/bin/tcsh slackware
[root@node2 ~]# grep slackware/etc/passwd
slackware:x:2002:2016 ::/home/slackware:/bin/tcsh
(8) Adding additional Group admins for user Slackware;
[Root@node2 ~]# groupadd Admins
[root@node2 ~]# usermod-g Admins slackware
[root@node2 ~]# ID slackware
u id=2002 (Slackware) gid=2016 (distro) group =2016 (distro), 2018 (admins)
(9), bit slackware add password, and require a minimum password to use the period is 3 days, the longest 180 days, warning for three days;
[Root@node2 ~]# passwd-n 3-x 180-w 3 slackware
Adjust user password aging data slackware.
passwd: Operation successful
(10), add user OpenStack, its ID is 2003, the basic group is clouds, the additional group is Peguin and Nova;
[Root@node2 ~]# useradd-u 2003-g clouds-g peguin-g nova OpenStack
[root@node2 ~]# ID openstack
uid=2003 (openst ACK) gid=2020 (clouds) group =2020 (Clouds), 2019 (Nova)
(11), add the system user MySQL, request its shell for/sbin/nologin;
[Root@node2 ~]# useradd-s/sbin/nologin MySQL
(12) Use the Echo command to add a password to the OpenStack interactively.
[Root@node2 ~]# echo ' 123.abc ' | passwd--stdin OpenStack Change the password for the user OpenStack.
passwd: All authentication tokens have been successfully updated.
Thank you for reading, I hope to help you, thank you for your support for this site!