Chown in Linux and permissions
I wanted to give full permissions to some user in a folder.
I used for example
chown -R myuser /etc/myfolder
By doing ls -l on /etc/myfolder we can clearly see the owners of the file as: myuser root.
How can I remove myuser from being the owner of that folder? I used man chown and I searched on the web, but I can't find anything useful.
Top Answer/Comment:
In traditional Unix permissions, a file or folder can only be owned by one user. When you do chown -R myuser, you set myuser as the owner of that particular file.
When doing an ls -l, the two names you see are the owner and the group the file belongs to, e.g. myuser being the owner and root being the group. Please read Unix Permissions for a little more info.
If you want the folder to be owned by root again, just do a chown -R root on it.
If you want a user to have full permissions on a folder, here are some possibilities you have:
- Let the user own the folder with
chown -R myuser, and make sure the folder has read, write and execute access for that particular user, e.g. with chmod u+rwx.
- Add the user to a group that has read, write and execute access on the folder, e.g.
useradd -G root myuser, where root is the name of the group, and chmod g+rwx. You also need to change the group of the folder with chgrp -R root for this to work.
상단 광고의 [X] 버튼을 누르면 내용이 보입니다