Navigation

Home

Web Essentials

Basic UNIX Commands For Web Work

The following table lists some basic UNIX commands you will need when developing Web pages.

  • Words in courier font are commands and should be typed as they are printed.
  • Italicized words contained in brackets [italics] should be substituted with the filename or directory you wish to work with.
  • Remember that UNIX is case-sensitive - UPPER and lower case letters mean different things.

Table of Contents


List the files in the current directory:
ls

Displays the name of the files in the directory.

ls -l

Displays additional information (eg. permissions) about the files in the directory.

ls -a

Displays all files in the directory, including hidden files.

ls -al

Combines the previous two options.

Change (or move between) directories:
cd
[directory]

Moves to the directory specified by [directory]

cd ..

Moves up a directory - two periods represent the parent directory.

cd ~

Moves to your home directory - tilde represents your home directory.

Make a new directory:
mkdir
[directory]

Makes a new directory called [directory]

Display the (path of the) current directory you are in:
pwd

Displays the name of the current directory you are in.

Copy a file:
cp
[oldfile]
[newfile]

Creates a new file identical to [oldfile] but with the name [newfile]

Rename or move a file:

mv
[oldfile]
[newfile]

Renames [oldfile] to [newfile] within the same directory.

mv
[oldfile]
[directory/newfile]

Moves [oldfile] to a different [directory] with the name of [newfile].

Remove (delete) a file:
rm
[file]

Deletes [file]. The file cannot be recovered.

Change permissions on a file or directory so others (including the Web server) can see your Web files and see into your Web page directories:

Warning: Using chmod can make files and subdirectories in your account available to all other users. Using the commands below from within your public_html (Web page) directory will permit only the files and directories in the public_html directory to others and/or groups.

Directory permissions
chmod og+x
[directory]

Changes the permissions of the [directory] so others can pass into the [directory]. This is necessary so the Web server can access the [directory] in which your Web pages and graphics reside.

chmod og+x
[$HOME]

Changes the permissions of your home directory so others can pass into it. This is necessary so the Web server can pass through your home directory to the public_html directory where your Web pages and graphics reside.

Example: When John Doe uses the chmod command on his CENTRAL UNIX account (jdoe): chmod og+x [$HOME] will permit others and groups to execute files in the home directory of jdoe's Central UNIX account. However, others and groups cannot read files in jdoe's account.

File permissions
chmod og+r
[file]

Changes the permissions of the [file] so others and groups can read it. This is necessary so the Web server can read your Web pages and graphics.

chmod og+r *

Changes the permissions of ALL of the files in the current directory so others and groups can read it. This is also allows the Web server to read your Web pages and graphics.

Displaying a Department al Account (Library) list
ulib dir

Returns a listing of all Central UNIX Department Library Accounts with the Librarian to be contacted.