Linux chmod Change permission Properties command

Source: Internet
Author: User

Change permission Properties command chmod

chmod (change mode)-change-file access permissions

chmod is a command used to change the permissions of a file or directory, but only the owner and Superuser root of the file have this permission. There are two ways to change the permissions of a file or directory through chmod: One is to set permissions by means of a permission letter and an operator expression, and the other is to use numbers to set permissions.

There are two ways to change permissions: 1. Digital notation (commonly used) 2. Character notation

Digital permission notation:

chmod [Numeric combination] File name

R 4

W 2

X 1

-0

Character-type permission notation:

chmod [user Type] [+|-|=] [permission character] file name




chmod

User type Manipulating characters Permission characters




file or directory

U (user) + (Join) R
G (Group)

O (Others) -(minus) W
A (All) = (set) X

User or user group definition:

U represents a master user

G Representative Group

O on behalf of other users

A represents the owner, the group, and other users, which is all of the three users (or groups) above

Permission Definition Letter:

R stands for Read permission

W Stands for write permission

X represents Execute Permissions

Permissions increment or decrement characters:

+ Add a permission

-Cancel a permission

= Cancel all other permissions to give given permission


Command parameters:

-C: If the file permission has changed, it will not show its change action

-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 as subdirectories (that is, they are changed in a recursive manner)

--HELP: Show Auxiliary Instructions

--version: Display version


Examples of use of digital permissions:

Such as:

[Email protected] zdw]# ls-l 2.txt-rw-r--r--. 1 root root Notoginseng 14:30 2.txt

Owner: Root rw-=4+2+0=6

User group: Root r-x=4+0+0=4

Others: r--=4+0+0=4

The permission for the 2.txt file is 644

Change the 2.txt permission to-r-xrwxr-x

[Email protected] zdw]# chmod 575 2.txt[[email protected] zdw]# ls-l 2.txt-r-xrwxr-x. 1 root root Notoginseng 14:30 2.txt

Change permissions for files in ZDW folders and folders

[[Email protected] zdw]# ll zdwtotal 0-rw-r--r--.  1 root root 0  apr 28 09:56 e-rw-r--r--.  1 root root 0 apr 28 09:56  i-rw-r--r--.  1 root root 0 apr 28 09:56 q-rw-r--r--.  1  root root 0 apr 28 09:56 r-rw-r--r--.  1 root root 0  apr 28 09:56 t-rw-r--r--.  1 root root 0 apr 28 09:56  u-rw-r--r--.  1 root root 0 apr 28 09:56 w-rw-r--r--.  1  root root 0 Apr 28 09:56 y[[email protected] zdw]# ll  zdw -lddrwxr-xr-x. 2 root root 4096 apr 28 09:56 zdw[[email  protected] zdw]# chmod -r 755 zdw                        #使用-R assigns files to folders and folders [[email protected] zdw]#  ll zdwtotal 0-rwxr-xr-x. 1 root root 0 apr 28 09:56  E-rwxr-xr-x. 1 root root 0 apr 28 09:56 i-rwxr-xr-x. 1 root  root 0 apr 28 09:56 q-rwxr-xr-x. 1 root root 0 apr  28 09:56 r-rwxr-xr-x. 1 root root 0 Apr 28 09:56  T-rwxr-xr-x. 1 root root 0 apr 28 09:56 u-rwxr-xr-x. 1 root  root 0 apr 28 09:56 w-rwxr-xr-x. 1 root root 0 apr  28 09:56 y


Example of using character permissions:

Permission to add X to a user

[Email protected] zdw]# ls-l 1.txt-rw-r--r--. 1 Root bin 151 Apr 15:46 1.txt[[email protected] zdw]# chmod u+x 1.txt #u表示对前三位处理 + permissions on x [[email P Rotected] zdw]# ls-l 1.txt-rwxr--r--. 1 Root bin 151 Apr 15:46 1.txt #已加上x的权限

Empowering User Groups

[Email protected] zdw]# chmod g=rx 1.txt #给用户组rx的权限 [[email protected] zdw]# ls-l 1.txt-rwxr-x R--. 1 Root bin 151 Apr 15:46 1.txt

Also give permission:

[[email protected] zdw]# chmod u=wx,g=rwx,o=w 1.txt               #用, number separated, can be simultaneously empowered [[Email protected] zdw]# ls -l  1.txt               -- Wxrwx-w-. 1 root bin 151 apr 27 15:46 1.txt[[email protected]  zdw]# chmod ugo-w 1.txt                        #用-minus w privileges at the same time [[EMAIL PROTECTED] ZDW] # ls -l 1.txt      ---xr-x---.  1 root bin 151  Apr 27 15:46 1.txt[[email protected] zdw]# chmod a-x 1.txt                         &nbSP; #ugo相当于a, minus x permission [[email protected] zdw]# ls -l 1.txt    ---- R-----.  1 root bin 151 Apr 27 15:46 1.txt[[email protected]  zdw]# chmod +x 1.txt                           #什么都不填直接写 + number, also equivalent to all [[email  protected] zdw]# ls -l 1.txt   ---xr-x--x. 1 root bin  151 apr 27 15:46 1.txt


This article is from the blog "Write to Yourself", so be sure to keep this source http://zhaodongwei.blog.51cto.com/4233742/1768505

Linux chmod Change permission Properties command

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.