How do I set file permissions in shell accounts?

The chmod command changes file permissions.

Each file has an associated owner and group. The owner is a logon account, and the group is a possibly empty group of logon accounts. The read, write, and execute permissions (which can be set by the owner) can be different for the owner, group, and public (other). Permissions apply to directories as well as files.
Enter ls -l to find the permissions on the files and subdirectories in the current directory. This returns lines that look something like the following:

drwx------ 2 bobg comp  512 Jun  7 09:49 mydir 
-rwxr-xr-x 1 bobg comp  321 May 30 14:36 myscript

Each line describes one file. From left to right: the permissions, the number of links, the owner, the group owner, the size in bytes, the date and time of the last modification, and the file's name.

The chmod command changes file permissions.

For example chmod u+x file adds execute permission to file for the owner (user), where file is the name of the file;

use chmod u-x file to remove execute permission for the owner.


u indicates the file's owner (user),
g the owner's group,
o the public (other), or
a for all three.


r is read permission,
w is write permission, and
x is execute permission.

Need help?

Last updated: 

February 03, 2012

Browse by tag