To view the permissions for a Linux file: Ls-l file name
To view permissions for a Linux folder: Ls-ld folder name (in the same directory)
To modify file and folder permissions:
sudo chmod-(on behalf of type) XXX (owner) xxx (group user) xxx (other users)
Common commands for modifying permissions:
sudo chmod 600xxx (only the owner has read and write permissions)
sudo chmod 644xxx (owner has read and write permissions, group user only Read permissions)
sudo chmod 700xxx (only the owner has read and write and Execute permissions)
sudo chmod 666xxx (everyone has access to read and write)
sudo chmod 777xxx (everyone has access to read and write and execute)
========================chmod===============
Directive Name: chmod
Usage rights: All users
Mode of use: chmod [-CFVR] [--help] [--version] Mode file ...
Description: Linux/unix file access rights are classified into three levels: file owners, groups, and others. The use of chmod can be used to control how files are accessed by others.
Put the meter:
Mode: Permission set string in the following format: [Ugoa ...] [[+-=][RWXX] ...] [,...], where u represents the owner of the file, G indicates that the owner of the file belongs to the same group (group), and O denotes other persons, a means that all three are.
+ indicates an increase in permissions,-represents a cancellation permission, = Represents a unique set of permissions.
R is readable, w means writable, x is executable, x means only if the file is a subdirectory, or the file has been set as executable.
-C: If the file permissions have changed, the change action will be displayed
-F: Do not display an error message if the file permissions cannot be changed
-V: Show details of permission changes
-r: The same permissions change for all files in the current directory and subdirectories (that is, they are changed in a recursive manner)
--HELP: Show Auxiliary Instructions
--version: Display version
Example: Set the file file1.txt to be read by everyone:
chmod ugo+r File1.txt
Set the file file1.txt to be readable by everyone:
chmod a+r File1.txt
The file file1.txt and File2.txt are set as the owner of the file, and the same group as the person to which they belong can be written, but others other than the other are not writable:
chmod ug+w,o-w file1.txt File2.txt
Set ex1.py to only the owner of the file can perform:
chmod u+x ex1.py
Set all files and subdirectories in the current directory to be readable by anyone:
Chmod-r A+r *
In addition chmod can also use numbers to represent permissions such as chmod 777 file
The syntax is: chmod ABC file
Each of the a,b,c is a number that represents the permissions of the user, Group, and other respectively.
R=4,w=2,x=1
To rwx the attribute then 4+2+1=7;
To rw-the attribute then 4+2=6;
To r-x the property, 4+1=7.
Example:
chmod a=rwx File
And
chmod 777 File
Same effect
chmod ug=rwx,o=x File
And
chmod 771 File
Same effect
Use chmod 4755 filename to give the program root privileges
Directive Name: Chown
Usage rights: Root
How to use: chmod [-CFHVR] [--help] [--version] user[:group] File ...
Description: Linux/unix is a multi-person and multi-work system, with all files owned by the owner. The chown can be used to change the owner of the file. Generally speaking, this instruction is only used by the system administrator (root), the general user does not have the authority to change the other person's file owner, and does not have the authority to change the owner of their own files to other persons. Only the system administrator (root) has this permission.
Put the meter:
User: New file owner's user idgroup: The user group of the new file owner (group)-C: If the file owner has changed, the change action is not displayed-F: If the file owner cannot be changed, do not display the error message-H: Only the link is changed More, not the one that link really points to.-V: Shows the details of the owner change-r: the same owner change (that is, one-by-one change) for all files in the current directory and subdirectories--help: Display Auxiliary description--version: Display version
Example:
Set the owner of the archive file1.txt to the Users group user jessie:
Chown Jessie:users File1.txt
The owner of all files and subdirectories in the current directory is set to user Lamport of the Users group:
Chmod-r Lamport:users *
-RW-------(600)--only the master has read and write permission.
-rw-r--r--(644)--only the master has read and write permission, and the group user and other users have Read permission only.
-RWX------(700)--only the owner has read, write, and execute permissions.
-rwxr-xr-x (755)-The master has read, write, execute permission, but the group user and other users only read, execute permissions.
-rwx--x--x (711)-The master has read, write, execute permissions, but the group user and other users only execute permissions.
-rw-rw-rw-(666)--All users have file read and write permissions. This approach is undesirable.
-RWXRWXRWX (777)-All users have read, write, and execute permissions. More undesirable approach.
Here are two general settings for the directory:
DRWX------(700)-only the owner can read and write in the directory.
Drwxr-xr-x (755)-All users can read the directory, but only the owner can change the contents of the directory.
Reference article: http://blog.csdn.net/haydenwang8287/article/details/1753883
Linux file Permissions view and modify-chmod------Some common sense of getting started