Linux file and Directory Operations Basic command: chmod command

Source: Internet
Author: User
Keywords Linux chmod commands Directory operations
Tags access access rights basic basic command created directory directory operations document

The chmod command changes the access rights of a file or directory.

Let's take a look at this document first. At the shell prompt, type:

LS Sneakers.txt

The previous command shows this file information:

-rw-rw-r--1 Test test 39 March 12:04 Sneakers.txt

A lot of details are provided here. You can see who can read (R) and write (w) files, and who created the file (test), where the owner's group (test) is located. The information on the right side of the group includes the file size, the date and time created, and the file name.

The first column shows the current permission; it has 10 bits. The first digit represents the file type. The remaining nine bits are actually three sets of permissions for three different groups of users.

The three groups are: The owner of the file, the group to which the file belongs, and "Others", which are not previously included in the user and group.

-(rw-) (rw-) (runnable) 1 Test

| | | |

Type owner Group Others

The first project specifies the file type, and it can display several of the following:

D-Directory

-(stub)-Regular files (not directories or links)

L-a symbolic link to another program or file that is located elsewhere on the system

In the three groups after the first project, you can see the following types:

R-Files can be read

W files can be written

X-Files can be executed (if it is a program)

When you see a dash ("-") in the owner, group, or other person, this means that the appropriate permissions have not been granted. Can see the following sentence

-rw-rw-r--1 Test test 39 March 12:04 Sneakers.txt

The owner of the file (in this case, test) has permission to read and write to the file. Group Test also has permission to read and write Sneakers.txt, and other groups do not have any permissions. It is not a program, so neither the owner nor the group has permission to execute it.

Next we use chmod to change the file permissions, type the following command:

chmod o+w Sneakers.txt

The O+w command tells the system that you want to write files to other people sneakers.txt permissions. To view the results, list the details of the file again. Now, this file looks like the following output:

-rw-rw-rw-1 test test 39 March 12:04 Sneakers.txt

Now everyone can read and write to this file.

To remove read and write permissions from the Sneakers.txt, use the chmod command to suppress both read and write permissions.

chmod GO-RW Sneakers.txt

By typing GO-RW, you are telling the system http://www.aliyun.com/zixun/aggregation/18137.html "> Delete the read and write permissions of the group and others in the file sneakers.txt. The result is similar to the following output:

RW-------1 Test test 39 March 12:04 Sneakers.txt

When you want to use the chmod command to change permissions, remember them as shorthand symbols, because all you really have to do is memorize a few symbols.

The following is a list of shorthand notation meanings:

Authentication

U-owned file user (owner)

Group of G-Owners

o Other person (not owner or owner group)

A-everyone or all (U, G, and O)

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.