Linux File/directory permissions

Source: Internet
Author: User
Tags file type file readable file permissions

File type permission belongs to the main group directory name/file name
DRWX------2 Alice girls 4096 September 11:33 Alice
DRWX------2 Rose girls 4096 September 10:47 Rose
DRWX------2 Tom boys 4096 September 10:43 Tom

File type:-Normal file D directory

O (∩_∩) o~~ File/directory permissions:
1. User owner (creator U of main owner file)
2. Group G where Group owner is located
For example: Useradd-g girls Alice Alice belongs to the girls group
Useradd xiaohong default Xiaohong group name is Xiaohong
Alice and Rose are in the girls group.
3. Other o is neither user nor in the same group

Ls-l starts with 10 characters:
File type file/directory permissions
-File---------
D Directory owner Group Other

4. Three kinds of access rights: readable R, writable W, executable x
RWX------appear fixed rwx missing use-replace
R Readable r--100 4
W Writable-w-010 2
X executable--x 001 1

-rw-r--r--Normal file: 644 permissions of the digital expression method concise
Self: readable, writable same group: read-only other: read-only

D rwx r-x r-x directory: Permissions 755
Self: readable, writable, executable
Same group: readable, executable other: readable, executable

-rwx rwx rwx executable file 777
For all users: readable, writable, executable

The method of digital expression of right permission
421
0---
001 1--x
010 2-w-
011 3-WX
4 r--
101 5 R-x
6 rw-
111 7 rwx

5, summarize the file and directory of the various rules of authority:
1) file permissions: R readable can use VI, cat to view the contents of the file
W writable can be modified after saving
x executable can be run directly command is executable file

2) directory permissions: R readable LS directory, can see content
W writable can modify directory contents, such as new, delete directory
x executable can be CD in

6. Command to modify file/directory permissions: chmod
Role: U owner user
G Same group
o Other
A All of
Usage:
# chmod u+x 1.txt Add executable permissions for yourself
# chmod u-x 1.txt Remove executable permissions for yourself
# chmod g+w 1.txt Add writable permissions for the same group
# chmod a+r,g+w 1.txt All users are readable, the same group of writable
# chmod 777 1.txt Digital Expression method
RWX rwx rwx
# chmod 644 1.txt

Premise: Only the file owner, root user can change permissions

Case: Modify Alice Home directory permissions by root or Alice:
For O + Rx, other user xiaohong can enter the Alice home directory and can use Ls-l to view current content.
O+w Xiaohong can modify the file by root or Alice to modify the permissions for the 1.txt file. 644-646
rw-r--r--rw-r--rw-
chmod 646 1.txt

Linux File/directory 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.