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
3 Answers
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.
- 25,444
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.
- 5,627