User groups and Rights Management (II)
I. Miscellaneous Knowledge collation
1, after the last chapter, CHFN command: used to change the finger command display information . This information is stored in/etc in the passwd file, if you do not specify any options, the CHFN command will enter the question-and-answer interface, as follows:
[Email protected] testdir]# CHFN changing finger information for root. name [Root]:
-F real name
-H Home Phone
-O Office Address
-P Office Phone
-U online Help
-V Display version information
2, Chsh command: The user is all users;
-S change Shell type: (must write out the path name of the shell)
[Email protected] ~]$ chsh-s/bin/zsh changing shell for Gejingyi. Password: Shell changed.
-l list all shells, source is/etc/shells
-U Help
-V Displays version information and exits
3, getent passwd user directly displays a line of information in user's passwd;
Getent gpasswd GROUP
4, two commands: VIPW=VI/ETC/PASSWD
Vigr=vi/etc/group
Two commands: Used to check the integrity of the passwd file: Pwck
Used to check the integrity of the group file: GRPCK
5. OpenSSL rand-base64 num Specifies the random password for num digits
[email protected] testdir]# OpenSSL rand-base64 UP6RFG8MPMQ7C1DDW6U2I2MGTXWIONHJ5C+DB4HSYD4QOFKWZKHWUTP+K788GB 3a qybr0+5geg== [[email protected] testdir]# OpenSSL rand-base64 xfltzj+llbo+eg6m
6, the pipeline only receives the standard output; multi-line redirection is also known as in-place text.
7. The new user in Linux defaults to the home directory of the previous user, and the files previously belonging to the previous user become new users because the UID number is the same.
8, used to change the password algorithm: authconfig--passalgo=sha256 (MD5, etc.)--update
Ii. Detailed orders and examples
1. GPASSWD command: It is the/etc/group and/etc/gshadow management tool:
-A Add user to group
-D Remove a user from a group
-A Specify administrator
-M designation group member, and-a use almost
-R Remove Password
-R restricts the user login group, only members of the group can use NEWGRP to join the group;
2. Useradd command:
User created directly, need to use passwd to set password
-D takes the specified path to the home directory, and the path cannot exist.
-S shell specifies the user's shell type
-g specifies an existing group as the primary group, and does not establish additional groups with its own name as the group name;
-O mate-ou does not check UID uniqueness
-u specifies that the Uid;[uid_min,uid_max] value is defined in/etc/login.defs, and that its maximum value is not reached by default to 65535
UID_MIN 1000 UID_MAX 60000 # System accounts SYS_UID_MIN 201 SYS_UID_MAX 999 # # min/max values for automatic gid selection in groupadd # GID_MIN 1000 GID_MAX 60000 # system accounts sys_gid_min 201 SYS_GID_MAX 999
-g additional groups, groups need to exist beforehand
Useradd-g Wang,root,bin Zhao
-R Create System user
-N Do not create groups for users, use user as the primary group
-d-s Change the default useradd command using configuration,-s for Shell
New User Templates folder/etc/skel,useradd command default settings file/etc/default/useradd.
Third, after-school homework and practice
1. The path variable is displayed in a separate row for each directory:
[Email protected] ~]# echo $PATH | Tr ': ' \ n '/usr/local/sbin/usr/local/bin/usr/sbin/usr/bin/root/bin
2. Delete the blank line of the specified file: The original file is not changed here: the first method:
[email protected] testdir]# cat konghang.txt sdfd asdfasas dfgjkkfgh aeqwyqy [[email protected] testd ir]# Cat Konghang.txt | GREP-E [^[:space:]] sdfd asdfasas dfgjkkfgh aeqwyqy
The second method:
[email protected] testdir]# Cat Konghang.txt | Tr-s ' \ n ' sdfd asdfasas dfgjkkfgh aeqwyqy
3. Display each word (letter) in the file in a separate line with no blank lines:
[email protected] testdir]# Cat Konghang2.txt | Tr-s ' \ n ' | Tr ' \ n ' Hello i am liming hello i am xiaohong bye bye
4, the difference between soft and hard links:
A hard link is one file that uses multiple aliases (they have a common inode) and is essentially the same file. Because a hard link is a file with the same inode number with only a different file name, deleting a hard-linked file does not affect other files that have the same inode number. Hard links cannot be created on a directory, only files can be created, and hard links cannot span partitions.
A soft link (also called a symbolic link) differs from a hard link in that the contents of a file's user data block are directed to the path name of another file. Soft link is an ordinary file, but the content of the data block is a bit special, its content is the name of the source file number of characters. Soft links can be created on files or directories. The plus-s option indicates that a soft link is created. Deleting a soft link does not affect the file being pointed to, but if the original file being pointed to is deleted, the associated soft connection becomes a dead link.
5.
[Email protected] etc]# useradd-s/bin/csh-c "Gentoo distribution"-G root,bin gentoo [[email protected] etc]# ID GE ntoouid=1005 (Gentoo) gid=1006 (Gentoo) group =1006 (Gentoo), 0 (Root), 1 (BIN)
6.
[[email protected] etc]# groupadd admins [[email protected] etc]# useradd -G admins natasha [[email protected] etc]# useradd -G admins harry [[email protected] etc]# passwd natasha Change Users natasha 's password . new Password: invalid password: password less than 8 characters Re-enter new password: Sorry, the password does not match. new Password: invalid password: password less than 8 characters Re-enter the new password: passwd: All authentication tokens have been successfully updated. [[email protected] etc]# passwd harry Change Users Password for harry . new Password: invalid password:  Password less than 8 characters re-enter new password: passwd: All authentication tokens have been successfully updated.
[Email protected] etc]# useradd-s/bin/nologin Sarah [[email protected] etc]# passwd Sarah change user Sarah's password. New Password: invalid password: password less than 8 characters re-enter the new password: passwd: All authentication tokens have been successfully updated.
This article from "Jing Xuan," blog, declined reprint!
Linux Learning Blog 12