I want every user to have full permissions over a single directory(and all the contents). Is this possible, and how? Thanks.
-
Do you mean the guest session account or did you create a separate guest user account? – saiarcot895 Aug 02 '14 at 15:52
-
It's not a big deal if a guset has acces to this folder, but it's better that it doesn't. I mean real guest account, which you get when you install ubuntu. – Dusan Milosevic Aug 02 '14 at 21:20
3 Answers
As the guest session
user does not get added to the users
group you could simply do the following:
sudo chown -R $USER:users /var/privatefolder
sudo chmod -R 770 /var/privatefolder
The guest session user could then not access the contents of /var/privatefolder
Edit
Looks like users created in GUI or at installation are not added to Users group automatically. I assumed this to be true.
you would have to sudo usermod -a -G users username
This would need you to add users to the group manually thus making this answer by TuKsn just as easy.

- 10,517
-
I enter this and I cannot see the contents of directory. Please, help. – Dusan Milosevic Aug 02 '14 at 19:04
-
You as in the user? or you as in the Guest. can you please show the output of
ls -l /path/to/folder
– squareborg Aug 02 '14 at 19:09 -
-
-
-
-
@DusanMilosevic try
sudo chown -R $USER:users /opt/D3GO/
instead ofsudo chown -R $user:users /opt/D3GO/
– TuKsn Aug 02 '14 at 20:59 -
I'm afraid this only works for me, and not other users. Thank you. – Dusan Milosevic Aug 02 '14 at 21:15
-
-
Are your other users members of the "users" group? or were they created with
useradd
and not added to users group. – squareborg Aug 02 '14 at 21:17 -
@DusanMilosevic You can run this to add all your "human" user to the users group:
for u in $(awk -F: '$3 >= 1000 && $1 != "nobody" {print $1}' /etc/passwd); do sudo usermod -a -G users $u; done
based on: http://askubuntu.com/a/329689/265974 – TuKsn Aug 02 '14 at 21:38 -
-
@TuKsn This works, thank you. So, the combination of your answers solves the problem. I don't know whose answer to accept... Thank you very much! – Dusan Milosevic Aug 02 '14 at 22:40
-
I just tested this morning and it looks like users are not automatically added to the users group on creation with the GUI or even at installation. This seems incredible to me. You should accept @TuKsn as his a complete answer. – squareborg Aug 03 '14 at 06:26
You can create a group for all the user which should have access to this folder.
Create a new group:
sudo groupadd myNewGroup
Add a user to the group
sudo usermod -a -G myNewGroup username
Change user and group of the directory
sudo chown -R $USER:myNewGroup /path/to/dir/
Change the permissions of the directory
sudo chmod -R 770 /path/to/dir/
Or ug+rwx
more info for permissions http://permissions-calculator.org/
Edit: As Shutupsquare suggest you can use the group users which already exists. To add all human users to the group you can use:
for u in $(awk -F: '$3 >= 1000 && $1 != "nobody" {print $1}' /etc/passwd); do sudo usermod -a -G users $u; done
based on: https://askubuntu.com/a/329689/265974
-
The problem is that I "don't know" the username as I intend to use this on a multiple computers with different usernames. If the guest can access the directory, that's actually not a problem. – Dusan Milosevic Aug 02 '14 at 19:03
-
@DusanMilosevic: In that case you can simply make the directory "world writable":
sudo chmod -R 777 /path/to/dir
That won't automatically give write access to files created by other users, but everyone would be able to read everything. – Gunnar Hjalmarsson Aug 03 '14 at 07:10 -
-
Yeah, that's not what I usually suggest either, but to me it sounds like it's what @DusanMilosevic asks for. – Gunnar Hjalmarsson Aug 03 '14 at 17:50
You can get what you want to with adding users in particular group and then applying full permission to that group.
(echo $USER
& echo $LOGNAME
is helpful to get username and logname)
Example:
If/Let:
dir1
is directory to which you want to apply full permission to user,
user1
is user to which you want to give full permission,
group1
is existing or to be create for giving full permission.
Then following command-line information can help you:
group1
can be created using following command:sudo addgroup group1
user1
can be added togroup1
using following command:sudo adduser pandya group1
Now permissions can be applied using following commands:
sudo chown :group1 -R dir1 sudo chmod g+rwx group1
Explanation:
sudo chown :group1 -R dir1
will applygroup1
todir1
recursively by-R
(to all sub directories and files)sudo chmod g+rwx group1
will apply read+write+execution permission togroup1
- As
user1
is ingroup1
so-that nowuser1
has full permission viagroup1
fordir1
recursively!
Verification:
$ ls -ld dir1
drwxrwxr-x 3 pandya group1 4096 Aug 3 12:11 example
where drwxrwxr-x
indicates d
for directory 1st rwx
for owner(u=pandya
) permission 2nd rwx
for group(g=group1
) permission and r-x
for other(o) permission in ugo
manner.

- 35,771
- 44
- 128
- 188