Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have created a group named newgroup. But I didn't add my user to this group. Now I want give the write permission to this group for a specific file named sample.txt. I can use chmod if I am the member of this newgroup. Can I do this using sudo? How? I created this group using the following command

sudo groupadd newgroup
share|improve this question
up vote 7 down vote accepted

First, execute

sudo chown root:newgroup sample.txt

In that way you will change the owner of file sample.txt to be root and the group of this file to be newgroup.

Then run

sudo chmod g+w sample.txt

share|improve this answer
Thank you for quick reply. Will This chmod command change the permission for all groups or the groups related to my username? – shantanu Jun 24 '14 at 10:04
With the first command, the file sample.txt will belong to the group newgroup, so the chmod command add write permission only to this group. – Charo Jun 24 '14 at 10:12
But still i can read/write the file from my user without sudo. I am not the member of newgroup. Nobody is the member of newgroup. I run chmod 775 simple.txt after chown :newgroup simple.txt. I should not be able to modify the file from my user. But i can. Because still i am the owner of this file. user field in chmod is unavailable – shantanu Jun 24 '14 at 11:21
That is, if you want root be the owner ot the file sample.txt. – Charo Jun 24 '14 at 11:26
Let's improve the answer a little bit... – Charo Jun 24 '14 at 11:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.