Virtual Private Server User Guide
Internet and UNIX Basics
Changing File and Directory Permissions
Users can modify the permissions on files or directories they own by using the
chmod command. Regular users cannot modify the permissions of files or
directories that they do not own. Members of the sysadmin group, however, can
use the vchmod super command to modify the permissions on files and
directories that are owned by other users, except for those owned by the user
root. The root user, also known as the superuser, can change the permissions on
any file using the chmod command.
Whether using the chmod or the vchmod command, you can set permissions
explicitly using the permissions number system, or by assigning individual
permissions based on the user type. Examples of each method are given below.
Example 1: Setting permissions via the permission numbering system
Suppose you want exclusive read, write, and execute permissions to a file called
all.mine, which you own. According to the numbering system, the corresponding
number would be 700. To set these permissions, use the following command:
> chmod 700 all.mine
You can verify the permissions by issuing the ll command. The resulting output
displays the following permissions on the all.mine file:
rwx
Example 2: Giving yourself permission to execute a file that you own:
Each type of user can be represented by one of the following values:
u The user who owns the file (usually you)
g Members of the group to which the owner belongs
o Other users
a All users (includes u, g, o)
Using the "+" symbol indicates the adding of a permission, and using i i indicates
the removal of a permission.
So, to give the owner permission to execute a file, use the following syntax:
chmod u+x file1
This gives you execute permission for the file "file1".
Example 3: Giving members of the file's group permission to write to the
file:
chmod g+w file2
This gives the group permission to write to the file "file2".
Example 4: Giving read permission to all users for a particular type of file:
(The a includes "all" groups: u, g, o)
Technical Training Department
August 2004
1 12