About file and folder permission notes in Linux systems

Source: Internet
Author: User
Tags chmod file permissions

Linux basics, Linux file and folder permissions, do not have 777 permissions. Online tutorials are too complex?? The プ of the horse flies?..

First, view Linux file permissions

Ls-l (General)
LL (Ubuntu applies, equal to Ls-al)

Second, the permission designator

R (Read), W (write), X (Execute)
4 (Read), 2 (write), 1 (Execute)


The following examples illustrate:

-RWX------: The file owner has read, write, and execute permissions on the file.
-rwxr?r--: The file owner has read, write, and execute permissions, and other users have Read permission.
-rw-rw-r-x: The file owner and the same group of users have read and write permissions to the file, while other users have only read and execute permissions.
Drwx--x--x: Directory owners have access to read and write and access to the directory, other users can access the directory, but can not read any data.
DRWX------: Other users have absolutely no permissions on the directory except that the directory owner has full permissions.


Note: The directory must have executive power to read

Second, modify the Linux file permissions

Method One

Chmod-r 777 dir/
-R change all subfolders and folders in dir directory and dir
777 means to read, write, and execute the "file-owned user, user group, other user".

Method Two

chmod parameters: A (user and group), U (user), G (Group), 0 (other user)
chmod operator: + (plus),-(minus), = (given)

chmod +x file.txt (user, group, other user, plus executive power)
chmod u+x file.txt (user, plus executive power)

Example 4:

$ chmod a–x Mm.txt

$ chmod–x Mm.txt

$ chmod ugo–x Mm.txt

Third, Linux common file permissions

777 (Read and write execution, read and write execution, read and write execution)
755 (Read and write execution, read execution, read execution)
644 (Reading, reading, reading)
400 (read, prohibit, prohibit


Iv. permissions at the time of Creation

(1) The User ID (UID) is used to set the file owner, and the primary group is used to set up the user group (unless the directory where the file is created has sgid bit settings).
(2) the "umask" command allows default settings for the creation of new files in user accounts. Specifically, the umask is used to set the permission mask, and after the existing access rights are reduced, the default permissions are generated when the file is created. For example, the permission for Root is 777, and if the permission mask is set to 022, then both are subtracted to 755. Type the umask command at the command line to view the current settings, such as to modify the "umask" setting, enter: $umask number, such as: Umask 0022 (default), the "umask" command does not set text files and script files but only the execution bit in the directory.
(3) If you create a folder or file (in Umask 0022 for example), 777-022=755 the permissions to create the folder, and 666-022=644 the permission to create the file, the "Ls-l" is displayed: Rwxr-xr-x (folder), rw-r--r--(file)

Five, modify the permissions of the folder ──chmod

(1) The meaning of the parameter: Ugoa is the owner, group, other, all; + represents the Append permission;-Indicates delete permission; = Appends the specified permission and deletes other unspecified permissions.
(2) Use example: Append owner executable, delete group writable, change other read-only.
$chmod-C u+x,g-w,o=r file_name
(3) The permission can be expressed in letters or numbers, read (r) = 4, write (W) = 2, execute (or search) (x) =1 these numbers together to get the number for the chmod command. (Note: If you are using ACLs in a file or directory, using the digital mode chmod command invalidates the ACL)
Cases:
Owner permissions: Read + Write + Execute =4+2+1=7
Group permissions: Read + write = 4+2=6
Other User License permissions: Read =4
The command is: $chmod 764 file_name4. Use the command to change the subdirectory and file permissions in a directory once: Chmod-r 777 Directory Name parameter R is a recursive operation on a subdirectory

Vi. Comparison of practical rights modification examples

To view Linux file permissions: Ls-l file name
To view Linux folder permissions: Ls-ld folder name (in directory)
To modify file and folder permissions:
sudo chmod-(representing type) xxx (owner) xxx (group user) xxx (other user)
Commands for modifying permissions frequently:
sudo chmod 600xxx (only the owner has read and write permissions)
sudo chmod 644xxx (owner has read and write permission, group user only Read permission)
sudo chmod 700xxx (only the owner has read and write and permissions to execute)
sudo chmod 666xxx (everyone has read and write permissions)
sudo chmod 777xxx (everyone has read and write and Execute permissions)

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.