linux權限相關命令:
● id 顯示用戶ID
● chmod 修改文件權限
● umask 設置默認的文件權限
● su 以另一個用戶的身份運行shell
● sudo 以另一個用戶的身份執行命令
● chown 修改文件的owner
● chgrp 修改文件的group owner
● passwd 修改用戶的密碼
權限與二進制八進制的對應
八 二 權限
0 000 ---
1 001 --x
2 010 -w-
3 011 -wx
4 100 r--
5 101 r-x
6 110 rw-
7 111 rwx
在命令行中可以使用如下的簡寫:
u user的簡寫,但指的是owner;
g group的簡寫,指的是group owner;
o other的簡寫;
a all的簡寫;
u+x owner權限加執行權限
u-x owner權限移除執行權限
+x 即all+x
o-rw 即other-rw
go=rw 即group,other=rw
u+x,go=rx 即user+x, group&other=rx
umask的意義:
umask=0000,0666-0000=0666,即--- rw- rw- rw-
umask=0002,0666-0002=0664,即--- rw- rw- r--
umask=0022,0666-0022=0644,即--- rw- r-- r--
chmod參數解釋:
bob Changes the ownership of the file from its current owner to user
bob.
bob:users Changes the ownership of the file from its current owner to user
bob and changes the file group owner to group users.
:admins Changes the group owner to the group admins. The file owner is
unchanged.
bob: Change the file owner from the current owner to user bob and
changes the group owner to the login group of user bob.