Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want every user to have full permissions over a single directory(and all the contents). Is this possible, and how? Thanks.

share|improve this question
    
Do you mean the guest session account or did you create a separate guest user account? –  saiarcot895 Aug 2 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 2 at 21:20

3 Answers 3

up vote 1 down vote accepted

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:

  1. group1 can be created using following command:

    sudo addgroup group1
    
  2. user1 can be added to group1 using following command:

    sudo adduser pandya group1
    
  3. 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 apply group1 to dir1 recursively by -R (to all sub directories and files)
  • sudo chmod g+rwx group1 will apply read+write+execution permission to group1
  • As user1 is in group1 so-that now user1 has full permission via group1 for dir1 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.

share|improve this answer

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.

share|improve this answer
    
I enter this and I cannot see the contents of directory. Please, help. –  Dusan Milosevic Aug 2 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 –  Shutupsquare Aug 2 at 19:09
    
ls: cannot open directory /opt/D3GO/: Permission denied –  Dusan Milosevic Aug 2 at 19:52
    
As the user...... –  Dusan Milosevic Aug 2 at 19:52
    
ls -l /opt/ | grep D3GO –  Shutupsquare Aug 2 at 19:59

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: http://askubuntu.com/a/329689/265974

share|improve this answer
    
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 2 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 3 at 7:10
    
If it is not really necessary I would avoid 777 ... –  TuKsn Aug 3 at 9:03
    
Yeah, that's not what I usually suggest either, but to me it sounds like it's what @DusanMilosevic asks for. –  Gunnar Hjalmarsson Aug 3 at 17:50

Your Answer

 
discard

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.