Setting Read/Write/Execute Permissions in Linux

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.


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.


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