Linux user management and file permissions

Source: Internet
Author: User
In Linux, for files in the current system, there are owners, groups, and other users. these three types belong to users, but they only play different roles. The IDs of different users are also different: the administrator and the rootID are 0 system users (users who did not log on when the system is started) 1-499... in Linux, for files in the current system, there are owners, groups, and other users. these three types belong to users, but they only play different roles.
 
Different user IDs are also different:
 
Administrator. The root ID is 0.
 
System user (user who does not log on when the system is started) 1-499
 
Common user,> = 500
 
Group:
 
Private Group, system Group, Public Group
 
The user can belong:
 
Basic group, additional group (additional group)
 
The permission of the file has been mentioned. The following describes the permission of the Directory.
 
R; ls
 
W: create or delete an object
 
X: switch cd to this directory or ls-l file
 
 
Add a user and password:
 
# Useradd username
 
# Useradd-u UID username
 
-G GID (the group must exist beforehand)
 
-C "comment"
 
-D path (the directory itself cannot exist beforehand)
 
-S shell
 
-G additional group, which can contain multiple
 
-M: Do not create a home directory
 
# Passwd user password
 
# Passwd -- stdin
 
# Pwck check whether the password of each user is within the security period
 
 
Command for viewing user information:
 
# The id User name displays all types of user information
 
# Id-u name view user UID
 
-G name: View user GID
 
-G name: view the GID of the additional group
 
-G-n name: displays the group name.
 
 
# Finger name: view the user's full name, directory shell, and other information
 
 
Modify user information:
 
# Chfn
 
# Chsh name change the user's shell
 
# Usermod some command parameters are the same as useradd
 
-G: overwrite the original additional group when adding an additional group.
 
-A-G: The original additional group is retained when an additional group is added.
 
-L newname: modify the user name
 
-L account locking
 
-U unlock the locked account
 
# Chage-m modify the user's shortest time
 
-M maximum time
 
-W warning time
 
# Chown user name: the owner and Group of the file to be modified in the group name File. (if either the owner or the group can be omitted, this item is not modified)
 
 
Delete a user:
 
# Userdel-r name: delete the user's home directory
 
 
Some commands about the group:
 
# Groupadd group name add Group
 
-G GID group name specifies GID
 
-R: add a system Group
 
# Groupmod modify group information
 
-G GID: Group name: modify group GID
 
-N name: Group name: modify group name
 
# Add a password to the gpasswd group by group name
 
 
Command for modifying file permissions:
 
# Chmod 755 file modification permission, which affects all users
 
# The chmod 75 file user does not have any permissions for the group and others.
 
# Chmod u = the rw file owner has these two permissions
 
Add w permissions to the permissions of the g + w file Group
 
The r permission of other users in the o-r file is revoked.
 
A indicates the permission of all users for modification.
 
If the file is a directory, you can use-R to change the permissions of files in the directory.
 
# Chmod -- reference = directory modification Directory: Set the permission of the directory to be modified
 
 
 
 
 
 
 
This article is from "? I have been running ??? H "blog
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.