简体   繁体   中英

Grant permissions/change owner to a user

I have aa two folders /opt/tom and /opt/test/ that has the following permissions:

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

how can I grant the permission to a user called john so that it looks like this?

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

To change a user, you use (as root or with sudo ):

chown john tom test

To set the rights:

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

(2 will set SGID bit)

You can always add -R switch, so it will be a recursive change. It's worth adding, that usually setting SUID/SGID bits for a directory makes new files created in this directory inherit this options.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM