Foreword
How to manage the permissions of a file / directory it?
File permissions calling Linux / Unix is divided into three levels: file owner, group, others.
chmod rights management for a file or directory, the file or directory permissions are controlled to read (R & lt), write (w), execute (x) 3 kinds thereof represent read-write executables.
Modify Permissions command
chmod modify the file, directory permissions
- chomd u+x/tmp/testfile
- chomd 755 /tmp/testfile
chown Change the owner, is a group
chgrp can be changed independently is a group, not commonly used
Purview
Competence:
U, i.e. the owner of the file or directory User
g, i.e. belongs to a group of files or directories Group
o, Other addition to the file or directory belongs to the owner or a group, other users belong to this range
a, All i.e. all users including owner, owning group, and other users
Exercise
1 a.txt to the owner of the file given executable permissions
@SC02ZRC4KMD6N ~ % ls -l a.txt
-rw-r--r-- 1 user1 staff 14 3 29 14:43 a.txt
user1@SC02ZRC4KMD6N ~ % chmod u+x a.txt
user1@SC02ZRC4KMD6N ~ % ls -l a.txt
-rwxr--r-- 1 user1 staff 14 3 29 14:43 a.txt
2 to reduce the read permission is a group
user1@SC02ZRC4KMD6N ~ % chmod g-r a.txt
user1@SC02ZRC4KMD6N ~ % ls -l a.txt
-rwx---r-- 1 user1 staff 14 3 29 14:43 a.txt
3 to the other user settings only write-only privileges
user1@SC02ZRC4KMD6N ~ % chmod o=w a.txt
user1@SC02ZRC4KMD6N ~ % ls -l a.txt
-rwx----w- 1 user1 staff 14 3 29 14:43 a.txt
4 read permission to all users increases
user1@SC02ZRC4KMD6N ~ % chmod a+r a.txt
user1@SC02ZRC4KMD6N ~ % ls -l a.txt
-rwxr--rw- 1 user1 staff 14 3 29 14:43 a.txt
5 write permissions to other users in digital, and is a group of their own as read only
user1@SC02ZRC4KMD6N ~ % chmod 446 a.txt
user1@SC02ZRC4KMD6N ~ % ls -l a.txt
-r--r--rw- 1 user1 staff 14 3 29 14:43 a.txt
6 Create a default file permissions umask value is 666 minus
user1@SC02ZRC4KMD6N ~ % touch e.txt
user1@SC02ZRC4KMD6N ~ % ls -l e.txt
-rw-r--r-- 1 user1 staff 0 3 29 18:15 e.txt
user1@SC02ZRC4KMD6N ~ % umask
022