Pick a Free OS

File Permissions and the chmod/chgrp/chown commands

here g stands for group, + stands for giving permission (as against -

for taking permission away), r stands for read permission.

so g+r means ?give group read permission?. All users for the owners group

now have read permission to foo.txt

Now if they misbehave and u want to take their read permission away.

The command is the same as above, just substituting the + sign with a minus


chmod g-r /home/aarjav/foo.txt

As shown the general format of the command is

chmod -R/c/f/v [u / g / o / a] [+ / - / =] [rwxXstugo]


u : user

g: group

o : others

a : all

+ : give permission

- : take permission away

= : cause the permissions given to be the only permissions of the file

r : read permission

w: write permission

x : execute permission

X: execute only if it is a directory or already has execute permission for

some user

s : set user or group ID on execution

t : save program text on swap device

u : the permissions that the user who owns the file has for it

g : the permissions that the owner?s group has for a file

o : the permissions that users not in the owner?s group have for it

(X, s, t, u, g and o are not required for common tasks)

the initial options -R/c/f/v are explained as follows :

-c : Displays names of only those files whose permissions are being changed

( --changes can also be used instead of -c )

-f : Suppresses display of error messages when a file?s permissions cannot

be changed

( --silent of --quiet can also be used instead of -f )

-R: Recursively changes the permission of all files in all subdirectories

of the directory whose

permissions are being changed

( --recursive can also be used )

-v : Displays results of all permission changes

( --verbose can also be used )

The chown command

The chown command is used to change the user and/or group which owns one

or more files or directories. Its general format is :

chown [-Rcfv] [username][:.][groupname] foo.txt

The flags used above are same as those used in the chmod command . The

following are the different ways in which this command can be used :