One, user management commands
User Information file:/etc/passwd
aa:x:501:501: null:/home/aa:/bin/bash
First column: User name
Second column: Password bit
Third column: UID user id=> more than 500 ordinary users
Fourth column: GID initial group ID
Fifth Column: User description
Sixth column: Home directory
Column seventh: Permissions after a user logs on
User category: Superuser (Root) General user system User (pseudo user)
Shadow files:/etc/shadow
Group files:/etc/group
Initial group: There can be only one initial group per user, typically a group with the same user name as the initial group
Additional groups: Each user can belong to more than one additional group. To add users to a group, add additional groups
1. Add Users
Useradd User Name
Useradd option User Name
Options:
-G Group name specifies the initial group
#useradd-G root Moshou Specify the initial group
#tail/etc/passwd
-G Group name Specify additional groups, add users to groups, use additional groups
#useradd-G root Lianmeng Specify additional groups
-C Add Description
#useradd-C "Qiangdadduishou" Buluo
-D Manually specify the home directory, the directory does not need to establish/home/
#useradd-D/admin Admin
-S default:/bin/bash Manually specify permissions after user logon
#useradd-S/bin/nologin test Disable login
2. Set the password
passwd User Name change the user password
passwd changing the current user password
passwd Root Change root password
3. Delete users
Userdel User name Delete user (delete user information only)
Userdel-r User name and home directory deleted together
4. Add a group
Groupadd Group Name
5. Delete a group
Groupdel Group Name Note: There are no initial users in the group.
6 Adding an existing user to a group
GPASSWD-A User name Group name user Join group
GPASSWD-D User Name Group name remove user from group
Second, user-related commands
1. ID User name displays UID, initial group, and additional group of user
#id Tianqi View the user's ID
2, Su-user name Switch user identity
-Switch with environment variables
#su-Switch User identities
Third, ACL permissions to the special identity of the user set permissions.
1. getfacl filename Query file ACL permissions
2. Setfacl option file name to set ACL permissions (set setting)
-M Set permissions
-B Delete permission
To set ACL permissions on a file
#getfacl index.php to view ACL permissions for a file
#setfacl-M u:tianqi:rwx index.php to set ACL permissions for Tianqi
#ls-L index.php
#getfacl index.php
#setfacl-M g:xuebao:rwx index.php to set ACL permissions for the Xuebao group
#getfacl index.php
To set ACL permissions on a directory
1)
#setfacl-M u:tianqi:rwx www
#getfacl www
#ls-ld www
#cd www
#getfacl Install.log
2) Set ACL permissions on directories and files within directories
#setfacl-M U:tianqi:rwx-r www
#getfacl www
#cd www
#getfacl Install.log
3) ACL permissions for future files in the directory (default permissions)
#cd www
#touch a.txt b.php
#getfacl A.txt
#setfacl-M D:u:tianqi:rwx-r www
#getfacl www
#cd www
#touch c.html
#getfacl c.html
Remove ACL permissions
#setfacl-B index.php
#getfacl index.php
#setfacl-X U:tianqi www
#setfacl-B www
#getfacl www
Note: If you give ACL permissions to the directory, all two commands are entered
-R recursion
-M u: User name: Permissions-r only for files that already exist
-M D:u: User name: Permissions-r only for future files to be created
Iv. output Redirection
1. Output redirection
Redirect the output that should be output to the screen to the file.
> cover ls > AA overlay to AA
>> append ls >> aa append to AA
LS gdlslga 2>>AA error message output to AA emphasis: Error output, cannot have spaces
2 Error message
LSS >> AA 2>&1 error and correct both input to AA, can be appended
2>&1 REDIRECT standard error to standard correct output
LSS >> AA 2>>/tmp/bb correct information input AA, error message input BB
V. Scheduled Tasks
Cyclic timing tasks:
CRONTAB-E Editing timed tasks
* * * * * command
First: 0-59 minutes in one hour
Second: The first hours of the day 0-23
Third: One months of the first day 1-31
Fourth: The year of the first few months 1-12
Fifth: Week of the week 0-6
Command: Enable/disable service sshd start service sshd stop
/usr/local/apache2/bin/apachectl restart
Restart system reboot Shutdown-r now
Generate file echo "good moring" >>/root/hello.txt
Backup files/Directories cp/root/hello.txt/tmp
Crontab-l Viewing system timing tasks
Crontab-r Deleting a scheduled task
Linux (iv) User and user group management