chown(Change owner) 用來改變某個文件或目錄的全部者和所屬的組,該命令能夠向某個用戶受權,使該用戶變成指定文件的全部者或者改變文件所屬的組。用戶能夠是用戶或者是用戶ID,用戶組能夠是組名或組ID。只有文件主和超級用戶才能夠便用該命令。oracle
chown [選項]... [全部者][:[組]] 文件... 或:chown [選項]... --reference=參考文件 文件... 更改每一個文件的全部者和/或所屬組。當使用 --referebce 參數時,將文件的全部者和所屬組更改成與指定參考文件相同。
[root@oracledb dir1]# ll 總用量 0 -rw-r--r-- 1 root root 0 4月 24 15:04 log [root@oracledb dir1]# chown oracle:dba log [root@oracledb dir1]# ll 總用量 0 -rw-r--r-- 1 oracle dba 0 4月 24 15:04 log
[root@oracledb dir1]# chown -v oracle:dba log "log" 的全部者已保留爲oracle:dba
[root@oracledb ~]# ls -ld dir1/ drwxr-xr-x 2 root root 4096 4月 24 15:04 dir1/ [root@oracledb ~]# chown -Rv oracle:dba dir1 "dir1/log" 的全部者已保留爲oracle:dba "dir1" 的全部者已更改成oracle:dba
[root@oracledb dir1]# chown -v oracle: log "log" 的全部者已更改成oracle:oinstall
[root@oracledb dir1]# chown -v :dba log "log" 的全部者已更改成:dba
[root@oracledb dir1]# chown -v 0:0 log "log" 的全部者已更改成0:0 [root@oracledb dir1]# ll 總用量 0 -rw-r--r-- 1 root root 0 4月 24 15:04 log
[root@oracledb dir1]# ll 總用量 0 -rw-r--r-- 1 oracle dba 0 4月 24 15:04 log1 -rw-r--r-- 1 root root 0 4月 25 20:27 log2 [root@oracledb dir1]# chown --reference=log2 log1 [root@oracledb dir1]# ll 總用量 0 -rw-r--r-- 1 root root 0 4月 24 15:04 log1 -rw-r--r-- 1 root root 0 4月 25 20:27 log2