Permissions to view Linux files: Ls-l file name Uluitug
Uluitug
To view the permissions for a Linux folder: Ls-ld folder name (in directory) Uluitug
Uluitug
Modify file and folder permissions: Uluitug
Uluitug
sudo chmod-(representing type) xxx (owner) xxx (group user) xxx (other user) Uluitug
Uluitug
Commands for modifying permissions frequently: Uluitug
Uluitug
sudo chmod 600xxx (only the owner has read and write permissions) Uluitug
Uluitug
sudo chmod 644xxx (owner has read and write permission, group user only read permission) Uluitug
Uluitug
sudo chmod 700xxx (only the owner has read and write and permissions to execute) uluitug
Uluitug
sudo chmod 666xxx (everyone has read and write permissions) Uluitug
Uluitug
sudo chmod 777xxx (everyone has read and write and Execute permissions)
========================chmod===============
Directive Name: chmod
Use Rights: All users
How to use: chmod [-CFVR] [--help] [--version] Mode file ...
Description: Linux/unix file access rights are divided into three levels: file owners, groups, others. The use of chmod can be used to control how files are accessed by others.
The meter:
Mode: Permission set string, the format is as follows: [Ugoa ...] [[+-=][RWXX] ...] [,...] where u represents the owner of the file, G means that the owner of the file belongs to the same group (group), o means other people, and a says all three are.
+ means to increase permissions,-to indicate cancellation rights, = to represent a unique set of permissions.
R means readable, W is writable, X is executable, x means only if the file is a subdirectory or the file has been set to executable.
-C: Display the change action if the file permissions have actually changed
-F: Do not display error messages if the file permissions cannot be changed
-V: Show details of permission changes
-r: The same permission changes are made to all files under the current directory and subdirectories (that is, to be changed one at a time)
--HELP: Show Auxiliary Instructions
--version: Display version
Example: Set the file file1.txt to be readable by all people:
chmod ugo+r File1.txt
Set the file file1.txt to be readable by all people:
chmod a+r File1.txt
The file file1.txt and File2.txt are set to the owner of the file and are writable by the same group as which they belong, but others are not writable:
chmod ug+w,o-w file1.txt File2.txt
Set ex1.py as only the owner of the file can perform:
chmod u+x ex1.py
All files and subdirectories under the current directory are set to anyone can read:
Chmod-r A+r *
In addition chmod can also use numbers to indicate permissions such as chmod 777 file
Syntax is: chmod ABC file
Each of these a,b,c is a number, representing the permissions of user, Group, and other respectively.
R=4,w=2,x=1
To rwx the property is 4+2+1=7;
To rw-the property is 4+2=6;
To r-x the property is 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 make this program have root permissions
Directive Name: Chown
Use Rights: Root
Use mode: chmod [-CFHVR] [--help] [--version] user[:group] File ...
Description: Linux/unix is a multiple-person work system, all files are owned by the owner. Using Chown, the owner of the file can be changed. Generally speaking, this instruction is only used by the System Manager (root), the general user does not have the authority to change other people's file owners, and does not have the authority to change their own file owners to others. Only the System Manager (root) has such permissions.
The meter:
User: New file owner user idgroup: The new owner of the file (group)-C: If the owner of the file has indeed changed, it will show the change action-F: If the file owner cannot be changed, do not display an error message-H: Change only for link (link) Rather than the file that link really points to-----show details of the owner change-r: The same owner change to all files in the current directory and subdirectories (that is, to be changed one at a time)--help: Show Auxiliary Instructions--version: Display version
Example:
To set the owner of the file file1.txt as the user of the Users group Jessie:
Chown Jessie:users File1.txt
All files and subdirectories under the current directory are set up as users of the Users group Lamport:
Chmod-r Lamport:users *
-RW-------(600)--only the owner has read and write access.
-rw-r--r--(644)--only the owner has read and write access, while the group users and other users have access only.
-RWX------(700)--only the owner has the right to read, write and execute.
-rwxr-xr-x (755)--the owner has the right to read, write, execute, and the group of users and other users only read, execute permissions.
-rwx--x--x (711)-The owner has the right to read, write, execute, and the group of users and other users only execute permissions.
-rw-rw-rw-(666)-All users have file read and write permissions. This practice is not advisable.
-RWXRWXRWX (777)-All users have read, write, execute permissions. More undesirable approach.
The following are two common settings for a 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.