Linux common command 16 file permission management

1, Meaning of ls-l paragraphs

wang@wang:~/workpalce/threading$ ls -l
//Total dosage 16
drwxrwxr-x 2 wang wang 4096 12 month 19 17:17 a
-rw-rw-r-- 1 wang wang  636 12 month 19 10:59 test.py
-rw-rw-r-- 1 wang wang  596 12 month  5 12:10 th.py
-rw-rw-r-- 1 wang wang  590 12 month 19 10:58 thtest.py

The first field has a total of 10 '-', the first '-' represents the file type: '-' is a normal file, b is a block special file, c is a character special file, d is a directory, l is a link file, p is a nine bar line after the pipeline file, three lines in a group, which can be rwxrwxrwwx, which represents that the access rights of the sequential owner, group and other users are readable, writable and executable.

If which position is still a bar, it means that there is no corresponding permission for this position. For example, if it is "- rwxr--r --", it means: This is a normal file (the first bar), the owner has read, write, and execute permissions; the group has read-only permissions; other users have read-only permissions.

The second field represents the number of hard links

The third field represents the owner of the file

The fourth field represents the ownership group of the file

The fifth field represents the size of the file

The sixth to eighth paragraphs are the last revision time of the document

The last field is the name of the file.

2, Modify file permissions

The first field above is modified. Modify in numerical method.

wang@wang:~/workpalce/threading$ ls -l
//Total dosage 4
-rw-rw-r-- 1 wang wang 590 12 month 19 10:58 thtest.py
wang@wang:~/workpalce/threading$ chmod 555 thtest.py 
wang@wang:~/workpalce/threading$ ls -l
//Total dosage 4
-r-xr-xr-x 1 wang wang 590 12 month 19 10:58 thtest.py
wang@wang:~/workpalce/threading$ chmod 641 thtest.py 
wang@wang:~/workpalce/threading$ ls -l
//Total dosage 4
-rw-r----x 1 wang wang 590 12 month 19 10:58 thtest.py

3, Modify the owner of the file

wang@wang:~/workpalce/threading$ ls -l
//Total dosage 4
-rw-r----x 1 wang wang 590 12 month 19 10:58 thtest.py
wang@wang:~/workpalce/threading$ sudo chown python thtest.py 
wang@wang:~/workpalce/threading$ ls -l
//Total dosage 4
-rw-r----x 1 python wang 590 12 month 19 10:58 thtest.py
wang@wang:~/workpalce/threading$ sudo chown :python thtest.py 
wang@wang:~/workpalce/threading$ ls -l
//Total dosage 4
-rw-r----x 1 python python 590 12 month 19 10:58 thtest.py
wang@wang:~/workpalce/threading$ sudo chown wang:wang thtest.py
wang@wang:~/workpalce/threading$ ls -l
//Total dosage 4
-rw-r----x 1 wang wang 590 12 month 19 10:58 thtest.py

Tags: Linux Python sudo

Posted on Sat, 02 May 2020 00:52:43 -0700 by Meissa