IUPUI integrated images

Web by Design logo
Home Tutorials Resources Kudos CV



After over a decade of service to the web community, I have made the decision that Web by Design has served its purpose and lived a fruitful life. It is time to shutter the doors and move on. However, due to the fact that so many continue to reference this tutorial, I will keep it available for the near future.

Thank you for your support over the years. It has been a pleasure.


UNIX Basics


Table of Contents

Introduction to UNIX at IUPUI

UNIX is an operating system developed by AT&T Bell Laboratories. It is a multi-tasking, multi-user system. This means that it can do many things simultaneously for many users, and for each user it seems as though it is working only for him/her, making it an ideal environment for central web servers.

IUPUI's initial widely used central UNIX system, named INDYUNIX.IUPUI.EDU, provided the IUPUI campus with many popular programs, including gopher and news reader clients, programming languages, alternate shells, a scripting language, two popular editing programs, and two E-Mail programs, in addition to being the home of the campus web server.

In an effort to alleviate congestion on INDYUNIX, in summer 1996, all student computing services were moved to a new system, CORD.IUPUI.EDU. The CORD system provided the IUPUI student population with Lynx (a text-based web browser), newsgroup readers, mail readers, and other general purpose computing applications, in addition to being the home of students' web home pages. In fall 1996, CHAMPION.IUPUI.EDU was brought online to handle all other E-Mail and web services.

The INDYUNIX machine was renamed COMET.IUPUI.EDU at that time and was used for other UNIX-based applications. It has since been retired. E-mail services for faculty, staff and students were moved to the Jewel or Outlook servers, leaving CORD and CHAMPION as the campus web servers. University Information Technology Services provides web space on the central servers for the campus community.

Institutional home pages are located on the machine CHAMPION.IUPUI.EDU. Institutional pages are those for departments, schools, official university organizations, or those related to a faculty member's professional, research or course interests. Home pages on CHAMPION must use an institutional Network ID rather than a personal Network ID. The URL for institutional pages on CHAMPION is http://www.iupui.edu/~networkid.

Each home directory on the CHAMPION system is allotted an initial disk quota of 100M for use with web files (more is available at an annual cost). If you need a quota increase, send E-mail to actadmin@iupui.edu.

Back to Top

Entering UNIX Commands

UNIX is a command-driven system and is CASE-SENSITIVE. In all but a very few cases (usually in the Vi editor or Elm E-Mail package), you must type UNIX commands in lower-case letters.

Back to Contents

Other References

UNIX Basics. Written by University Information Technology Services. The document contains basic UNIX commands.

Learning the UNIX Operating System. Published by O'Reilly & Associates, Inc. (ISBN: 1-56592-060-0). The cost is about $25. Written by Grace Todino, John Strang, and Jerry Peek. Contains basic, generic UNIX information and commands. It is clearly written and contains good examples. It is not particularly "techie."

Back to Contents

Preparing your UNIX Champion Account for a Home Page

CHAMPION is the campus institutional web server. This means that web pages created by departments, official organizations, and schools, as well as faculty course, research, and professional pages are housed on CHAMPION. All Network IDs on CHAMPION are "institutional" rather than "personal." When you logon to a CHAMPION account, you are placed automatically in your home directory. A home directory is designated by a ~ (tilde) followed by a Network ID. For example, my home directory is ~webtrain.

Web files in CHAMPION accounts are placed in the www directory. This directory will already be present in your account.

When web pages are housed on UNIX servers, the account owner must give permission, via a command, so that the web server can read the directory contents and files. Otherwise, the web browser returns an error message when the URL is accessed. This action is handled automatically for web accounts on CHAMPION using a utility called umask. Umask automatically sets the permissions for the www directory and any subdirectories you create within it, as well as any files you place within those directories.

Back to Contents

Transferring Files to your Web Space

The process to transfer HTML and graphics files to your web space is called ftp (file transfer protocol). WS_FTP is a common application for Windows and Fetch is the most common Mac ftp application. For other basic information on ftp, see FTP on a PC. Each application works conceptually the same.

Back to Contents

Logging on to CHAMPION

Telnet is an application that allows you to access a remote host by indicating the domain name of the server you want to access. At IUPUI telnet has been replaced by SSH (secure shell) which provides a more secure way to access a server.

NOTE: type the host name in lower-case letters.

From home, after you have connected to the network via either the IUPUI modem pool or your ISP (Internet Service Provider), you can use SSH to connect to Champion. IUPUI faculty, staff, and students can install SSH from the IUWare CD.

At the prompts, type your Network ID and password, respectively. You will know that you have successfully logged on when you receive the scrolling welcome message and the system prompt.

Back to Contents

About Wildcards

Many UNIX commands can be issued with shortcuts when there are similarities among file names. UNIX wildcards include the * (asterisk) which replaces any number of characters, and the ? (question mark) which replaces a single character. The * wildcard is the more widely used of the two.

For example, if I have files named logo.jpg, fountain.jpg, tube.jpg, and foodcrt.jpg, I could manipulate the group by referring to them as *.jpg, meaning that all the files existing in this location ending in .jpg would be affected. If I have blproj1.htm, blkproj1.htm, and pnkproj1.htm, I could effect a change on only the first two files by referring to them as bl*.htm

Back to Contents

Changing Directories

When you work with home page files housed in multiple directories, you will need to change directories to access the various sets of pages.

To change directories, type: cd directorytochangeto

After logging in to CHAMPION, to change into my web directory, I will type: cd www

If I am in my www directory and want to change into my Images subdirectory, I will type: cd Images

To Change Multiple Directories In One Step

Assume you create a subdirectory (and call it Images) within your www (CHAMPION) directory. For example,

Sample Directory Structure

Sample Directory Structure

To move directly into the Images directory from your home directory, type: cd www/Images. The alternative would be to make the move in two separate steps: cd www, then cd Images.

To Return To Your Home Directory

From wherever you may go in a UNIX system, to return to your home directory, type: cd

To Move Up One Level

To return up one directory level, type: cd ..

NOTE: There is one space between the cd and the ..

Back to Contents

Moving Files

To move files from one directory to another, make sure you are in the directory that CONTAINS the file, then type the command followed by the name of the file(s) to be moved and the destination: mv filetomove destinationdirectory

  1. Log into your CHAMPION account.

  2. If the file to be moved is in your home directory and needs to be in your web directory, type: mv filetomove www

    If I transferred the file bigtoe.gif to my home directory (instead of my web directory as it needs to be), I need to move it to the www directory. After logging into my account, I will type mv bigtoe.gif www.

    If I transferred the file staff.html to my web directory and it needs to be in the web subdirectory, Personnel, I will log into my account. At the prompt, I'll type cd www to change into my web directory. Then to move the file, I'll type mv staff.html Personnel

Back to Contents

Where Am I?

To find out exactly which directory you are in, type: pwd

This will return a path statement.

If I move to my www directory, then type pwd, I will see: /home/webtrain/www

Back to Contents

Getting a List of Files

To get a simple file listing, showing only the file and directory names, type: ls

Options "expand" the functionality of a given command. To use UNIX options with a command, type: command -option. (That is, the command followed by a space, followed by a dash, followed by the option.)

If I type ls -F each directory will be designated with a / at the end of the name:

home.html   logo.jpg    Graphics/

Example: for a listing more useful to web developers, type ls -la to see the long attributes:

drwxr-xr-x 1 jsmith staff 1024 May 18 12:56 .
drwxr-xr-x 402 sys sys 7680 Jan 15 06:23 ..
-rwxrwxr-- 1 jsmith hrstaff 276 May 10 17:54 home.html
-rwxrwxr-- 1 jsmith hrstaff 512 May 10 17:59 logo.jpg
drwxr-xr-x 5 jsmith hrstaff 8192 May 1 02:59 Graphics

This tells you (reading from left to right) the permissions of each file or directory, the number of links to that file or directory, the owning Network ID, the type of account or the group name, the file/directory size in bytes, the date and time of creation or last modification, and the file/directory name.

Think of the first section (the permissions) as a single column followed by three sets of three:

-,- - -,- - -,- - -

The single column indicates whether it is a directory (d) or a file (-). The remainder of the sets taken as a whole are the permissions for the given directory or file. The first set of three indicates what the owner (user) may do, the second set of three indicates what any group members (group) may do, and the final set of three indicates what everyone else (others) may do.

The permissions are read, write and execute. You can think of the permissions as: u+r+w+x,g+r+w+x,o+r+w+x filename That is, the user (owner) may read, write and execute the file, any group members may read, write and execute the file, and others may read, write and execute the file.

Back to Contents

Using the Change Mode Command

CHAMPION uses umask which automatically sets the permissions on the www directory and any subdirectories and files therein. So there is no need to use the chmod command if you are using that server.

However, if you ever use a UNIX Web server that does not automatically set permissions you will need to make sure that your readers, via their web browsers, can read your files, but not change anything. The previous section identified the permissions as u+r+w+x,g+r+x,o+r+x (absolute reference). All those pluses and letters are tedious to type and lead to making typos. Each of the permissions in UNIX is assigned a numeric variable; that provides a shortcut for us when setting permissions (relative reference). To see the permissions of your files and directories, type: ls -la

UNIX will return a listing similar to:

drwxr-xr-x 2 sking staff 1024 Nov 25 12:37 .
drwxr-xr-x 12 sking staff 2048 Nov 24 09:06 ..
-rw-r--r-- 1 sking staff 45802 Nov 19 16:16 home.html
-rw-r--r-- 1 sking staff 45012 Nov 20 13:37 howard.html
-rw-r--r-- 1 sking staff 47740 Nov 20 13:40 welcomsg.html
-rw------- 1 sking staff 29783 Nov 25 12:37 xray.html

Notice that the "new" file xray.html is not the same as the others; if you tried to access it with a web browser you would receive a "403 - Forbidden" error. To correct that problem, I will type chmod 644 xray.html:

-rw-r--r-- 1 sking staff 29783 Nov 25 12:37 xray.html

For Directories

At IUPUI, if a web directory contains a file named home.html, that page is automatically displayed when the URL is entered—even without including the file name home.html. However, if a directory does not contain a home.html file, generally a listing of all the files in the directory are displayed. This listing is allowed when the permissions of a directory have been set by typing: chmod 755 directoryname

To prevent a listing of your files from displaying, you can set the directory permissions by typing: chmod 711 directoryname

If you are working on personal home page files, type: chmod 644 filename

For Files

If there are similarities among your file names and you are issuing the command manually, you can use wildcards to change like groups of files at one time.

All home pages end in.html, so you could change them all at once by typing: chmod 644 *.html

Groups of image files could be changed by typing: chmod 644 *.jpg

By far the easiest is to change all files: chmod 644 *.* — Even if you have already set the permissions for existing files, issuing the command with *.* will not harm any files, but will be sure to catch any that you may have previously missed.

Back to Contents

Changing the Name of a File

To change the name of a file, type: mv oldfilename newfilename

I named a file billygoats.html, but someone has pointed out that the pictures in the file are really nanny goats. To rename my billygoats.html file, I would type: mv billygoats.html nannygoats.html

You cannot move/rename a group of files with wildcards. For example, it would be nice to use the command mv *.htm *.html—but unfortunately that won't work.

You can create a file that will allow you to easily change the name of all files created with an .htm extension to .html, follow these steps:

  1. Log into your account and change to your www directory by typing: cd www

  2. Type: pico rename2html

  3. Type: #!/bin/csh

  4. Press Enter once more (to give a blank line).

  5. Type: foreach file (*.htm)

  6. Type: mv $file 'basename $file .htm'.html

  7. Type: end

    Your file should look like this:

    foreach file (*.htm)
    mv $file 'basename $file .htm'.html

  8. After proofing your typing, press ^x — hold the Control key and type: x

  9. At the Save modified buffer prompt, type: y

  10. At the File Name to Save: rename2html prompt, press ENTER

From then on, after you have transferred files to your web directory, at the prompt, type: rename2html and all your files will be renamed correctly.

Back to Contents

Other Helpful UNIX Commands

To delete a file, type: rm filename

(BE CAREFUL! You CAN delete groups of files with wildcards and there is NO UNDELETE!!)

To create a directory, type: mkdir directoryname

A UNIX rule of thumb is to create directories with an initial cap and files with all lower-case letters so that they are easy to distinguish when listing the files, but the Champion www directory name MUST be lower-case.

To remove a directory, type: rmdir directoryname

NOTE: A directory must be empty before it can be removed and you can not be inside the directory when you issue the remove directory command.

Back to Contents

Getting Help

To get information about a UNIX command, type: man commandname

To learn about the move command, type: man mv

UNIX will return a great deal of information on how to use the mv command.

To move to subsequent screens of information, press the spacebar.

To stop reviewing the command before the actual end, press ^c — hold the Control key and type: c

Back to Contents

Logging Out

Type: exit