Owner (user), owning group, others (other)
Because Linux is a multi-tasking system, it often appears that the same machine is operated by more than one person at a time, in order to consider everyone's privacy and the work environment that everyone likes, so the attribution of the file is very important.
In order to ensure the security of the system and the privacy of the file, a file with different permissions for the account has different permissions, such as
, the file permission is represented by a string representing the meaning of the
Where the document type has the following representation:
D-the table of contents, for example, the line with the name ". GConf" in the above file;
--the document, for example, the line with the "Install.log" in the above file;
L-Link file (link file);
B-the storage Interface device (optional random access device) inside the device file;
C-the serial port device inside the device file, such as a keyboard, mouse (one-time reading device).
The permissions are represented by rwx three subtitles, respectively, as readable, writable, executable, if not, then "-" means, for the directory, must have X permission, otherwise cannot read the contents of the Directory
If the file name is preceded by ". "indicates that the document or directory is hidden.
Users and user groups
/etc/group Storing user group information in the current system
Attention:
1. When there is only one user in the group, and the user name and group name are the same, in the group list, a column containing the user can be empty
2. The group number of the root group in the system must be 0
3. Group number 1~499 is the group number reserved for the system, usually the number of software or service reserved for the system installation, the earlier the Software or service group number is installed. User manually created user group number starting with 500
4. Group password placeholder, no exception, all denoted by x
/etc/gshadow Store password information for user groups in the current system
Attention:
1. If the group password is "*"! "Or empty, the group does not have a password
2. If the group manager is empty, it means that all members within the group can manage the group
/ECT/PASSWD Store all user information in the current system
Attention:
In Linux, the user number for Super Admin root must be 0
/ect/shadow Store password information for all users in the current system
Attention:
Password is a one-way encrypted string
To create a user:
Useradd xxx // Create a user named XXX
After the command executes
1. Information about XXX Users is added to the/etc/passwd file
2. A user group message named XXX is added to the/etc/group file
passwd xxx // set password for XXX user
Useradd parameters that can be used include
-D Set the user's home directory -d/home/helloworld Hello // new Hello user and set their home directory to/home/ HelloWorld-u set its userid 668 Hello // Create a new Hello user, set his ID to 668 -G set its primary group -G root Hello // Create a new Hello user and put it if the root group -m Create a folder for your home directory -M Hello // Create a Hello user, and a Hello folder (/home/hello) in the default location, and copy the files under/etc/skel to this directory
Modify user Information
Usermod parameter User name
The parameters that the command can use include
-L // Modify new user name For example: Usermod-l helloworld Hello change Hello user name to HelloWorld, but its home directory does not change -U // Modify user's UserID 888 Hello to change the userid of Hello to 888-D // Modify the user's home directory -G // Modify the user's primary user group -L // Lock the user so that it cannot log on- u // unlock
Delete User
Userdel parameter User name
Parameters can be used
-R Delete the user while deleting its home directory
Create a user group
Groupadd Group Name
Modify a user group
Groupmod-n New group name old group name / Modify Group name -G new group ID old group ID modify Group ID
Delete a user group
Groupdel Group Name
Change the owner of a document (catalog) (all groups)
Changing the document owner-chown command (change owner), you can use the parameter-R to make its subdirectories also modified
Adapt document all Groups-chgrp command (change group), use the parameter-R to make its subdirectories also modified
You can also use
Chown
To modify the owner and group of a document or directory at the same time
Modify the execution permissions for a document
chmod command
chmod parameter file name
You can set permissions for a file directly by using the following method
1 . Directly set a number that represents permissions chmod 777 (number of corresponding permissions) file name 2 . To add or subtract certain permissions from a file chmod u+w filename to user user plus W permission chmod g-r file name remove R permission from group chmod a+x file name to user, group, other all plus x permission
Organize self-teaching net (www.imooc.com)
Linux users, user groups, and permissions