向用户授予权限/更改所有者权限

时间:2013-04-02 20:40:35

标签: linux permissions

我有两个文件夹/opt/tom/opt/test/,它们具有以下权限:

drwxr-xr-x. 2 root root 4096 Apr  2 16:23 tom
drwxr-xr-x. 2 root root 4096 Apr  2 16:16 test

如何将权限授予名为john的用户,使其看起来像这样?

drwxr-sr-x 3 john root 4096 Dec  5 13:22 tom
drwxrwxrwx 3 john root 4096 Apr  1 16:45 test

1 个答案:

答案 0 :(得分:1)

要更改用户,请使用(以root身份或使用sudo):

chown john tom test

设置权限:

chmod 777 /opt/test
chmod 2755 /opt/tom

(2将设置SGID位)

您始终可以添加-R开关,因此它将是递归更改。值得补充的是,通常为目录设置SUID / SGID位会使在此目录中创建的新文件继承此选项。

相关问题