標籤:linux command
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.
the linux command line學習筆記之四