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?– saiarcot895Aug 2, 2014 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 MilosevicAug 2, 2014 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.
-
I enter this and I cannot see the contents of directory. Please, help. Aug 2, 2014 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
Aug 2, 2014 at 19:09 -
-
-
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.
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. Aug 2, 2014 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. Aug 3, 2014 at 7:10 -
-
Yeah, that's not what I usually suggest either, but to me it sounds like it's what @DusanMilosevic asks for. Aug 3, 2014 at 17:50