How do I change the group ownership of a file in Ubuntu? [closed]
Asked Answered
M

3

7

I have a little question on how to change the group owner of a file. At the moment the group of the file is the same as my user name but I want to change it so another user can access that same file and read/write to it.

Meatman answered 18/2, 2014 at 21:37 Comment(1)
i know how to do it if i just right click in properties but i want to learn how to do it in the terminalMeatman
T
11

The syntax would be

chown user:group file ...

This usually (=when you're not root) only works as long as you are a member of the same group (since otherwise by chown'ing files you could exceed the other user's disk quota).

If you both are in the same group you could also allow write access with

chmod g+w file

As above this will allow all members of group write access.

If you do not share a common group, all you can safely do is to allow read access to the file so the other user can make a copy of it and edit his/her copy.

Tittup answered 18/2, 2014 at 21:40 Comment(0)
S
7

You can do it using chown:

$ chown :friends myfile

This would change the group of myfile to friends.

Spandau answered 18/2, 2014 at 21:39 Comment(1)
so its chown :newgroupname file?Meatman
L
3

Also don't forget to change the file permissions to 660 that will give read, write, permission for the owner ( you ) and read, write permission for the new group.

Example:

-rw-r-----  1 martin martin          0 Feb 18 21:41 test

$ chown martin:newgroup test

$ chmod 660 test 

-rw-rw----  1 martin newgroup          0 Feb 18 21:41 test
Lenny answered 18/2, 2014 at 21:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.