I. Know/etc/passwd and/etc/shadow.
1. passwd Construction
Is the user information of one user in passwd, expressed as [user name] [Password] [uid] [GID] [comment] [Home Directory] [Shell]
2. Shadow Construction
[User name] [Password] [number of days since the last password change on January 1, January 1, 1997] [past ~ The password can be changed only after a day.] [expiration date] [before the password expires ~ Daily Warning] [Blank by default] [Blank by default]
Note: If the password is !!, Indicates no password
If the password is *, this account is not allowed to log on.
2. Add a user
1. groupadd [-g gid] groupname
2. useradd [-u uid] [-g gid] [-G extragid] [-M] [-D path] Username
-D Indicates pointing the root directory to the specified path
-G indicates the additional group, that is, GID is the main group, and extragid is the additional group (milk =-=)
-M indicates that the root directory is not created.(But his file exists !!)
It is worth noting that-M cannot be followed by Su-username, because there is no root directory of username, so if you want Su-username, you need
Mkdir/home/username, CP-r/etc/skel/home/username, so that you can use this command, because the user's environment variable initialization and other things are
In/Etc/skeLFolder
3. userdel [-R] Username
-R: Delete the [Home Directory] and [/var/spool/mail/username] of the account.
4. usermod [to be supplemented]
Iii. User identity Switching
1. Su
Su-c "Touch/tmp/username.txt"-Username
Indicates using the command with username identity(Common)
2. sudo and mongodo [Sudo-u username] [command]
Grant temporary permissions to a common user
Eg: Sudo-U test touch test
Indicates that the root user can execute the test USER command to create the test file
4. Others
1. How to disable remote root login
Modify/etc/ssh/sshd_config and change Yes to No.
Restart the service/etc/init. d/sshd restart.
(SSH is the client, and sshd is the server)
2. You only need to enter the password once.
1) passwd -- stdin username (interaction)
2) echo "New passwd" | passwd -- stdin username (non-interactive)
3) echo-e "New passwd \ nNew passwd" | passwd username (non-interactive)
//////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// ///////////////
Gorgeous split line
//////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// ///////////////
Today, I felt like I had to learn Linux well, and I had an idea during my class today. I also summarized the things in "Computer Network" here.
The summary can also be used as the materials for my end-of-term review. I feel that the sauce purple is quite good. Anyway, let's say that. Come on.
People are confused because they think too much and do too little.
[Centos] Account Management