UNIX commands for Web developers
A quick guide to the essential UNIX commands required for remote maintenance of a Web site.
cd - change directory
cd - return to root directory
ls - list contents of current directory
ls -a - all files
du - disk usage
du - report disk usage in
"blocks" (512 bytes)
exit - Sever connection with the server
chmod - Change permissions (or "mode") of a file or directory
e.g. chmod 755 animate.cgi - the file "animate.cgi" can be read and executed by anybody and can also be changed by the owner of the file.
A file (or directory) can be readable, writeable, and executable. Permissions to read write and execute can be set separately with local, group-wide, or global scope.
If a permission is local, it refers only to local users (usually the maintainer of the Web site); if a permission is global, it refers to anyone gaining access to a site from anywhere (including the Internet). In general, if a Web site is being maintained by one person using a single user account, access permissions of group-wide and global scope will generally be set to the same value.
The three digits that are used as arguments of the chmod command define the access permissions of the file (or directory) that is entered immediately after them. The first digit defines permissions with local scope; the second, group scope; and the third, global scope.
Read permission is arbitrarily given a value of 4; Write permission has a value of 2; permission to execute is 1, so that a single digit between 0 and 7 uniquely defines the access permissions for a given scope.
0 no permissions;
For directories, access permissions mean something similar. To gain access to a directory, execute permission is required. To change files, write permission is required. To display a default index file or to list the directory contents if no index file is present, read permission is required.
Here are some common uses of the chmod command:
chmod 711 miscellaneous
- make a directory accessible to the world;
General Rules of Thumb
Directories should be set to 755, or 777 if a script is adding and removing files inside the directory - and always have an index page.
Documents should be set to 644, or 666 if they are being changed by a cgi script. Scripts should be set to 755.
If your site is a collaborative venture, user and group permissions should be the same, i.e. 775 and 664, instead of 755 and 644.
Hyperlative Ltd. ©1997