UNIX Primer

Home | Primer Home


Permissions

Every file in the UNIX filesystem has what are known as 'permissions' associated with it. Permissions determine who is and is not allowed to read, write, and execute the given file. Each file also has an 'owner' and 'group' associated with it as well. Using the 'chmod' command (as seen below), we can determine what access the owner, group, and the world at large (aka. other) are allowed (ie. read, write, execute). We can also change the owner of a file using the 'chown' command. Using these commands, we can share files with other users.

Often, we need a mutually accessible place to store files that we wish to share. In this case, we can use the '/tmp' directory on the machine we are using. By placing files in '/tmp' using 'cp' or 'mv' and changing the permissions, owner or both, we can allow other users to gain access to files.

By default, the permissions placed on a newly created file are determined by your 'umask.' Your 'umask' is a number (represented in octal) which represents the complement (opposite) of the permissions that will be placed on newly created files. You can change your umask using the 'umask' command.

Related Commands:

NameMeaningPurpose
chmod CHange MODe Change the permissions on a given file or files.
Syntax
chmod <permissions> <file(s)>
Notes
  • permissions argument consists of the following: who(+/-)mode(s)
    • Who: u = user, g = group, o = other
    • Modes: r = read, w = write, x = execute
    • Example: o+rw --- gives others (all users) read and write permission
    • Example: u,g-x --- takes away execution from user and group
  • permissions argument can be expressed in octal as well. see 'man chmod'

NameMeaningPurpose
chown CHange OWNer Change the owner of a given file or files.
Syntax
chown <person> <file(s)>

NamePurpose
umask Change the default permissions for new files.
Syntax
umask <mask> (see 'man umask')

See Also:


Designed by D. Kaminsky
Edited by Diana Palsetia
© University of Pennsylvania, 2008