5

I just created a group and I am looking to add RWX to root and the group. What command(s) can I use to set the permission to? Also I would like world to have NO permissions

8

From the commandline the command is "chmod"

The Read/write/execute permissions is in the form of User/Group/Others.

If you want to remove the permissions you can issue the command:

$ chmod ugo-wrx testfile

That will take away all the permissions from the testfile.

If you want to have only the User (the owner of the file) have access you can issue:

$ chmod u+wrx testfile

After removing all the permissions now the only permissions on the file would be (w)rite, (r)ead, e(x)ecute by the owner of the file.

You could add the group full access to the file with:

$ chmod g+wrx testfile

You can also give everyone full access to the file by issuing:

$ chmod ugo+wrx testfile

Notice in the commands there is either a minus "-" or a plus "+". The minus removes the specific permission the plus adds the permission.

You can get more details of the usage by issuing at the command prompt:

$ man chmod

You can check the permissions of the file with the "ls -l" command:

$ ls -l testfile

The argument of ls is specifying the long output.

| improve this answer | |
  • Thanks much! I was thinking that you can set permissions to a user first and then change it's ownership to that user but this will do just as well – ryekayo Jun 9 '14 at 23:18
  • Actually you can set the user or group in any order. The final permissions will be what you end up with. If the initial owner is john and you set where only john has access, that's the way it will be. If you change the owner to paul, then only paul will have access if the permission is user only. As you test the options the way you have described, you'll notice lots of flexibility and variations of the command. – L. D. James Jun 9 '14 at 23:27
1
chown root:yourgroup target_file
chmod 1770 target_file

1770 means it's rwx for the owner and the group, and no permission for the world, and new files and subdirectories will inherit these permissions. (1 = sticky, 7 = 4 + 2 + 1 = r + w + x)

To do this on directories recursively, add a -R switch to the end.

| improve this answer | |
1

use:

umask 007

in .bashrc of users that belong to group.

This mask results in default permissions of 770 for new directories and 660 for new files created by users.

User root can access all file, but if you want to access root file from users, you need ACL

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.