Changing Permissions
When you create a file, UNIX automatically gives the user read and write permissions (depending upon how your umask is set). This is the default mode. Often you will want to change the permissions assigned to a particular file or directory. You may only change the permissions if you are the owner of the file or directory.
$ chmod – command to change permissions, “change mode”
followed by: whose permission u – for user (file’s owner) g – for group o – for other (everyone else) a – for all three ex. $ chmod g – the beginning of a command to change the permissions assigned to the group for this file.
followed by: what to do to the permission + – ‘add,’ ‘allow,’ ‘yes,’ ‘okay,’ or ‘turn on,’ this permission - – ‘subtract,’ ‘no,’ ‘don’t let them,’ or ‘turn off’ this permission = – to explicitly state what permissions you are allowing ex. $ chmod g- – you are going to remove a permission that was previously given to that group.
followed by: what permission to change r – read permissions w – write permissions x – execute permissions ex. $ chmod g-w – you are no longer allowing the group to modify or delete this file or directory.
followed by: filename – the name of the file or directory you are changing the permissions of ex. $ chmod g-w test – you are no longer allowing the group to modify or delete the file test.
examples: $ chmod g+r finances – allow the group to read the finances file $ chmod go-w finances – don’t let anyone but the user change the file $ chmod g=rwx – the group can read, write and execute
Changing modes using numeric permissions $ chmod 644 finances – don’t let anyone but the user change the file $ chmod 750 test – owner can do all, group can read and execute, everyone else can do nothing