5

I want to grant a single user write permissions to a directory owned by root over command line. With chmod, it seems that I can only change the permissions for owner, group and other, not for a specific user.

Hannesh
  • 153

2 Answers2

5

If filesystem is mounted with the acl option (default in ext4 in any modern Ubuntu - if not, add it to /etc/fstab), you can use setfacl:

setfacl -m u:USERNAME:r FILENAME

would give user USERNAME read access to FILENAME.

Olorin
  • 3,488
Kees Cook
  • 17,473
1

By default in Ubuntu every user belongs to a group with the same name, i.e. hannesh:hannesh.

You can make the folder owned by root:hannesh, and give it permissions like 770 though I see no reason for it to be owned by root if you want the user to be able to write there - why doesn't hannesh:hannesh suit you? Root would be able to write in that folder anyway.

Also have a read about the sticky bit if root creates files in that directory which need to be writeable by the user.

Sergey
  • 43,665