Many operations on Ubuntu are performed on the terminal. Files managed by the sudo command are owned by the root user, which cannot be changed by the general user. On the graphic interface, you can use the permission options folder in the attribute to perform operations. However, once the file property shows that the current user has no read/write permissions, the permissions cannot be modified on the graphic interface.
The common method is as follows:
Sudo chmod 600 ××× (only the owner has read and write permissions)
Sudo chmod 644 ××× (the owner has the read and write permissions, and the group user only has the read permission)
Sudo chmod 700 ××× (only the owner has the permission to read, write, and execute the CHMOD)
Sudo chmod 666 ××× (everyone has read and write permissions)
Sudo chmod 777 ××× (everyone has the permission to read, write, and execute the CHMOD)
××× Indicates the file name (or folder name, but-LD must be added after chmod ).
To explain, the entire command is actually in the form
Sudo chmod-(representing the type) ××× (owner) ××× (group user) ××× (other Users)
Each digit of the three-digit number represents a user-type permission setting. The value ranges from 0 ~ 7, that is, the binary [000] ~ [111].
Each digit of the three binary numbers represents the read, write, and execution permissions respectively.
For example, "000" indicates that no three permissions are available, and "100" indicates read-only. In this way, we have the following correspondence:
0 [000] No Permissions
4 [1, 100] Read-Only permission
6 [110] Read and Write Permissions
7 [111] Read and Write execution Permissions
Now let's take a look at the common usage above. Try to modify the permission on your own.
Finally, the command for querying the file (or folder) Permission is attached.
Ls-l file name (Change-L to-LD in the folder ).
Original article address:Http://liufeng2008.blogspot.com/2008/08/ubuntu.html
Bytes -----------------------------------------------------------------------------------------------------------------
Chmod usage
Command name: chmod
Permission: All Users
Usage: chmod [-CFVR] [-- help] [-- version] mode file...
Note: file access permissions for Linux/Unix are classified into three levels: file owner, group, and others.
Chmod can be used to control how files are accessed by others.
Calculation:
Mode: permission setting string in the following format: [ugoa...] [[+-=] [rwxx]...] [,...],
U indicates the owner of the file,
G indicates that the archive owner belongs to the same group,
O indicates someone other than others,
A indicates that all three are.
+ Adds a permission,-Indicates canceling the permission, and = indicates a unique permission.
R indicates that the file can be read, W indicates that the file can be written, and X indicates that the file can be executed only when the file is a subdirectory or the file has been set to executable.
-C: if the permission of the file has been changed, the change action is displayed.
-F: Do not display an error message if the file permission cannot be changed.
-V: displays details of permission changes.
-R: Change the permissions of all files and sub-directories in the current directory in the same way (that is, change one by one in the way of delivery)
-- Help: displays auxiliary instructions
-- Version: displays the version.
Example: Set the file file1.txt to readable by all users:
Chmod Ugo + R file1.txt
-
Batch folder and subfolders
Chmod-r 755/var/www/thinkphp
Set file1.txt to readable:
Chmod A + R file1.txt
Set file1.txt and file2.txt as the owner of the archive, which can be written to the same group to which the archive belongs, but not to others:
Chmod ug + W, o-w file1.txt file2.txt
Set ex1.py to only the owner of the file to execute:
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 use numbers to indicate permissions, such as chmod 777 file.
Syntax: chmod ABC File
Each A, B, and C is a number, indicating the permissions of the user, group, and other respectively.
R = 4, W = 2, x = 1
If you want the rwx attribute, 4 + 2 + 1 = 7;
If the RW-attribute is required, 4 + 2 = 6;
If you want the R-x attribute, 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
If you use chmod 4755 filename, you can grant root permissions to this program.
Command name: chown
Permission: Root
Usage: chmod [-cfhvr] [-- help] [-- version] user [: Group] file...
Note: Linux/Unix is a multi-person, multi-job operating system. All archives have owners. Chown can be used to change the owner of an archive.
Generally, this command is only used by the system administrator (Root). Generally, users do not have the permission to change the owner of another user's archive or change their owner to another user.
Only the system administrator (Root) has such permissions.
Calculation:
User: user of the new archive owner
Idgroup: User Group of the new archive owner
(Group)-C: If the archive owner has changed, the change action is displayed.
-F: If the archive owner cannot be changed, do not display an error message.
-H: only the link is changed, not the file actually pointed to by the link.
-V: displays the details of the owner's changes.
-R: Change the owner of all files and sub-directories in the current directory in the same way (that is, change one by one in the way of delivery)
-- Help: displays auxiliary instructions
-- Version: displays the version.
Example:
Set the owner of the file file1.txt to user Jessie of the Users Group:
Chown JESSIE: Users file1.txt
Set all files in the current directory and sub-directory owner to user Lamport of Users Group:
Chmod-r Lamport: Users *
-RW ------- (600) -- only the owner has read and write permissions.
-RW-r -- (644) -- only the owner has read and write permissions, while the owner and other users have only read permissions.
-Rwx ------ (700) -- only the owner has read, write, and execution permissions.
-Rwxr-XR-X (755)-the owner has the read, write, and execution permissions, while the owner and other users have only the read and execution permissions.
-Rwx -- X (711) -- the owner has read, write, and execution permissions, while the owner and other users have only execution permissions.
-RW-(666) -- all users have the permission to read and write files. This approach is not advisable.
-Rwxrwxrwx (777)-all users have read, write, and execute permissions. It is not advisable.
The following are two common settings for the directory:
Drwx ------ (700)-only the owner can read and write data in the directory.
Drwxr-XR-X (755)-All users can read this directory, but only the owner can change the contents in the directory.