The Chmod__linux of Linux

Source: Internet
Author: User
Tags chmod readable file permissions

Chmod has been confused before, now summed up:

In UNIX and Linux operating systems, each file (the folder is also considered a file) is read, write, run set permissions.
For example, when I use the ls-l command column file table, I get the following output:
-rw-r--r--1 apple users 2254 2006-05-20 13:47 tt.html
From the second word Fu Qi rw-is said that the user Apple has read, write right, there is no right to run, then the r--that the user group users only Read permissions, no running rights, the last r--refers to other people (others) only read permission, no write right and run right. This is the system default setting, I can overwrite tt.htm, the same group of people and others only have the right to read, no one has the right to run, because just an HTML file, do not have to run. This was advanced prior to Novell's directory services.
Read, write, run three permissions can be expressed in numbers, that is r=4,w=2,x=1. So, the rw-r--r--in the example above is represented by a number of 644.
The converse 777 is rwxrwxrwx, meaning that the logged-on user (which can be viewed with a command ID), his group, and everyone else has the highest privileges.
Let me say one more word. I use the chmod o-r tt.htm command to change the permissions, O-r is the others of the permissions to reduce the read. The result is
-rw-r-----1 BU users 2254 2006-05-20 13:47 tt.htm
If you use the command to chmod 777 tt.htm, the result is
-rwxrwxrwx 1 bu users 2254 2006-05-20 13:47 tt.htm
Anyone who has read, write, and run three permissions.

---------------------------------------------
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.

Parameter format:

Mode: Permission set string, the format is as follows: [Ugoa ...] [[+-=][RWXX] ...] [,...], where

U: 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 unique permissions.
R: Is 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 effects are the same

chmod ug=rwx,o=x file and chmod 771 file effects are the same

If you use chmod 4755 filename, you can make this program have root permissions

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.