1. 程式人生 > >linux-第七課時筆記-[權限]

linux-第七課時筆記-[權限]

span 其他 中間 useradd linux 默認 use 用法 rwx

權限管理

Linux權限:

r : 讀

w : 寫

x : 執行

-rw-r--r-- 1 root root

- 文件(d 代表目錄)

3位一組

前3位是代表屬主的權限 rwx

中間3位代表屬組的權限 rwx

後3位代表其他用戶的權限 rwx

r 4 w 2 x 1

新建文件的默認權限

0664---- -rw-rw-r--.

最高權限是0666

新建目錄的默認權限

0755---- drwx-r-xr-x.

最高權限是0777

修改權限:chmod

用法:chmod 文件/目錄

Chmod 664 1.txt

[[email protected] ~]# ll 1.txt

-rw-r--r-- 1 root root 0 Aug 25 14:01 1.txt

[[email protected] ~]# chmod 664 1.txt

[[email protected] ~]# ll 1.txt

-rw-rw-r-- 1 root root 0 Aug 25 14:01 1.txt

Chmod u+r 1.txt (- w/x) 屬主 可加可減

Chmod g+r 1.txt (- w/x) 屬組 可加可減

Chmod o+r 1.txt (- w/x) 其他 可加可減

修改屬主屬組:chown

用法:chown [屬主:屬組] 1.txt

例如:

[[email protected] ~]# ll 1.txt

-rw-rw-r-- 1 root root 0 Aug 25 14:01 1.txt

[[email protected] ~]# useradd test

[[email protected] ~]# chown test:test 1.txt

[[email protected] ~]# ll 1.txt

-rw-rw-r-- 1 test test 0 Aug 25 14:01 1.txt

[[email protected] ~]# chown root 1.txt

[[email protected] ~]# ll 1.txt

-rw-rw-r-- 1 root test 0 Aug 25 14:01 1.txt

[[email protected] ~]# chown :root 1.txt

[[email protected] ~]# ll 1.txt

-rw-rw-r-- 1 root root 0 Aug 25 14:01 1.txt

linux-第七課時筆記-[權限]