Web Development Support
    General Info   Cool Tools
    Getting Started   Troubleshooting
    Design & Promotion   Feedback
 

Search this site:


view site map

Changing File Permissions Using Unix Commands

The following information will help you to use Unix commands to change file permissions. If you have not already done so, you may want to review the document Unix File Permissions. Please note that Unix can be a very user-unfriendly environment. For a start-to-finish tutorial on working in the Unix environment, please see Unix for Web Designers.

Directions for:

Single-user sites

The steps for correcting permissions errors on single-user sites are as follows:

  1. establish a secure connection (using SecureCRT or NiftyTelnet - both are available from Software Central) to the server which houses your web pages
  2. issue the Unix command chmod for any files or directories which need to be changed.

Scenario: User mst3k is getting a permissions error when trying to view his web site at http://www.people.virginia.edu/~mst3k.

After logging into blue.unix.virginia.edu with SecureCRT, mst3k issues the following on the Unix command line:

cd public_html

to go to the directory where his web page is stored. He then views the permissions by issuing the command:

ls -l home.html

and sees the following output:

-rw-r----- 1 mst3k staff 724 Jan 17 2001 home.html

Permissions are organized into three major groupings. In this example the permissions for user are rw-, the permissions for group are r--, and the permissions for other are ---.

This file is not viewable on the web because "other" does not have read permissions. To correct the problem, mst3k issues the command:

chmod o+r home.html

To verify that the command produced the desired results, mst3k again issues the command:

ls -l home.html

and sees the following output:

-rw-r--r-- 1 mst3k staff 724 Jan 17 2001 home.html

Provided that the permissions of the parent directories are correct, the page should now be viewable on the web.

The following chart outlines the recommended permission settings for the files and directories in single-user web sites:

Recommended Permissions for single-user web sites
File Permissions
User
Group
Other
read
read
read
write
-
-
-
-
-

rw-r--r--

Directory Permissions
User
Group
Other
read
-
-
write
-
-
execute
execute
execute

rwx--x--x


Group-maintained sites

The steps for correcting permissions errors on group-maintained sites are as follows:

  1. establish a secure connection (using SecureCRT or NiftyTelnet - both are available from Software Central) to the server which houses your web pages
  2. Verify that the group ownership of your files is correct
  3. issue the Unix command chmod for any files or directories which need to be changed.

Scenario: User mst3k is getting a permissions error when trying to edit the file home.html in the group-maintained site http://www.virginia.edu/somesite

After logging into minerva.acc.virginia.edu with SecureCRT, mst3k issues the following on the Unix command line:

cd /www/doc/somesite

to go to the directory where the web page is stored. He then views the permissions by issuing the command:

ls -l home.html

and sees the following output:

-rw-r--r-- 1 abc2d staff 724 Jan 17 2001 home.html

There are two problems with this file: (1) The group ownership is not correct; (2) group write permissions have not been set.

To correct this problem, mst3k goes to find the owner of the file - abc2d. Only the owner of the file may change the group ownership or permissions.

abc2d then logs into her account and repeats the steps above. To change the group ownership, she issues the command:

chgrp somegrp home.html

where somegrp is the group that was designated for this web site. She then adds group write permissions by issuing the command:

chmod g+w home.html

Finally, she verifies that the changes were made by issuing the command:

ls -l home.html

and sees the following output:

-rw-rw-r-- 1 abc2d somegrp 724 Jan 17 2001 home.html

Provided that mst3k is a member of the group somegrp, he will now be able to edit the file.

The following chart outlines the recommended permission settings for the files and directories in group-maintained web sites:

Recommended Permissions for group-maintained web sites
File Permissions
User
Group
Other
read
read
read
write
write
-
-
-
-

rw-rw-r

Directory Permissions
User
Group
Other
read
read
-
write
write
-
execute
execute
execute

rwxrwx--x

Please note that for group-maintained sites under www.virginia.edu, faculty.virginia.edu, and indorgs.virginia.edu, ITC can provide you with a utility that can correct many permissions errors on a nightly basis. If you think you may benefit from this service, please write to web-consult@virginia.edu to inquire.


Web Development Support | General Info | Getting Started | Design & Promotion
Cool Tools | Troubleshooting | Feedback

If you need further assistance with Web applications or questions, send e-mail to web-consult@virginia.edu or call the ITC Help Desk at 924-3731.

 

© 2008 by the Rector and Visitors of the University of Virginia.

The information contained on the University of Virginia’s Department of Information Technology and Communication (ITC) website is provided as a public service with the understanding that ITC makes no representations or warranties, either expressed or implied, concerning the accuracy, completeness, reliability or suitability of the information, including warrantees of title, non-infringement of copyright or patent rights of others. These pages are expected to represent the University of Virginia community and the State of Virginia in a professional manner in accordance with the University of Virginia’s Computing Policies.