How can i change the permissions of directory
public to all users only read and only
sudo users (group members of
sudo) to only read/write access.
I prefer to do it like this :
chown root:sudo ~/public
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
# make the group 'sudo' the owner of the directory 'public' chgrp sudo public # give the group read/write access and others just read access chmod g=rwx,o=rx public
ls -ld public drwxrwxr-x 2 pduck sudo 4096 Feb 4 14:08 public
If you also want to prevent the current owner
pduck from accessing the directory (regardless of his membership), then give the ownership to
sudo chown root:sudo public sudo chmod 0750 public # result: drwxrwxr-x 2 root sudo 4096 Feb 28 11:32 public
root and members of the
sudo group have read/write access. But
root can access the directory anyway, even when he's not the owner, so this is safe.
The first thought might be to keep the ownership and just reduce the rights:
sudo chown pduck:sudo public sudo chmod 0050 public # gives d---r-x--- 2 pduck sudo 4096 Feb 28 11:32 public
Now – although the owner –
pduck cannot access the directory. But (as owner) he can simply regain access by issuing
chmod u+rwx public himself, so this is not safe.