0
user@ubuntu:/var/www$ sudo addgroup webwork
[sudo] password for user: 
user@ubuntu:/var/www$ sudo chmod g+s /var/www
user@ubuntu:/var/www$ sudo chown :webwork /var/www
user@ubuntu:/var/www$ ls -l ../www
total 4
-rw-r--r-- 1 root root 177 2011-12-13 15:48 index.html

user@ubuntu:/var/www$ sudo usermod -aG webwork user
user@ubuntu:/var/www$ ls -l ../www
total 4
-rw-r--r-- 1 root root 177 2011-12-13 15:48 index.html

user@ubuntu:/var/www$ ls > t.txt
bash: t.txt: Permission denied

user@ubuntu:/var/www$ uname -n
ubuntu
user@ubuntu:/var/www$ whoami
user

I simply want to create a group of webwork and add the current user of user to this group so that it can modify the folder of \var\www.

Question> Why after running the above statement, the user still have no permission to modify the folder /var/www?

Thank you

// Update -- after logout and login //

user@ubuntu:/var/www$ ls -l
total 4
-rw-r--r-- 1 root root 177 2011-12-13 15:48 index.html
user@ubuntu:/var/www$ ls > t.txt
bash: t.txt: Permission denied
q0987
  • 956
  • Your ls command only shows the permissions of the contents of /var/www. Could you run ls -l /var and post the results? – Dennis Dec 13 '11 at 22:51

1 Answers1

1

Log out and log in again.

Each running process has its own credentials – user, group, secondary group list. When you run usermod -aG, you only update the user's information on disk, but you cannot update the group list of currently running shells. You can see it by running groups or id (shows current credentials) and comparing with groups user or id user (shows information on disk).

Also, make sure your group actually has write access (+w) to the directory. Add it with sudo chmod g+w /var/www.

u1686_grawity
  • 452,512