Publish Web Pages at UVM:

UNIX Commands You Will Need to Know:

Zoo uses UNIX, a complex operating system with many commands. However, you will only need to be familiar with a few of these to create and publish your Web pages. To use these commands you will have to telnet to zoo directly, login, and type the commands at the zoo prompt which looks something like this: username@zoo.uvm.edu>
If you don't have a telnet program, you can download and install one from the CIT web site:
http://cit.uvm.edu/software
 
 

Quick List

ls display a list of files in the current directory
pwd display the path and name of the current directory (print working directory
~ the tilde. Represents your home directory (the directory you start in when you login)
cd change directory
cd .. change to the directory above the current directory in the path
cd ~ go back to your home directory
mkdir make a new directory
chmod change the mode (the rights) to directories or files
man the online manual pages
cp copy files from one place to another or copy a file to a new name
mv move a file from one place to another, or change its name
del delete files
rmdir remove directories: you shoudl delete the files in the directory first
man the online manual pages

Descriptions and Examples

ls list files

 When you get an account on a host computer like Zoo/Moose, you are given a home directory. Since there are typically many accounts on a host computer it follows that there will be many directories. You can store files in your home directory and even create sub-directories within it to organize your files. After logging in to your account you can see a list of the files and directories in your home directory using the ls (list) command. 

Type ls <enter>: at your prompt. The computer will list the files and directories in the current directory. Directories have a slash (/) at the end of their names.

 ls by itself lists normal files and directories but there are several other ways to use this command. For example, some files in UNIX have special names. They have a dot preceding their name, like .signature and .forward. You can see these files with the ls command by typing: ls -a <enter>

 When you create a new file or directory zoo/moose automatically set rights for the file that prevent other people from seeing its contents. You can see how the rights are set for your files by typing ls -l (that's a lower case letter "L"). More inf ormation on these rights is given below in the section on the chmod command.
 
 

pwd print working directory

 Your home directory is probably itself a sub-directory of other directories. You can see what your directory is named and where it fits in the grand scheme of directories by using the pwd (print working directory) command.

 To use it, simply type pwd at your prompt and press <enter> You will see the "path" that leads to your home directory. The last item in that path is your home directory's name. On Zoo/Moose, that is probably the same as your login name.
 
 

cd change directory

 You can move from one directory to another using the cd (change directory) command. 

There are several ways to use this command:

 1) Type cd .. (that's: cd space dot dot) Then press <enter>.
This command changes your current or working directory to the directory just above yours in the path. For example, if you are at your home directory such as racka04/users/ugrad/jsmith, and you type cd .. you would now be at racka04/users/ugrad. How can you tell? Try the pwd command again. Want to see who else shares this directory with you? Try the ls command.

 2) Type cd dirname where dirname is the name of another sub-directory. (Remember, you can type ls to see a list of files and other directories in whatever directory you are currently working in.) 

UNIX is not very communicative. It will not tell you that it has changed to another directory. To verify that it has, type pwd.

 3) Type cd ~ <enter> (The ~ is called a tilde. You will find it on your keyboard, probably to the left of the number 1 key at the top of the typing keys.) The tilde has a special function. It represents your home directory. Thus, no matter which directory you are in, you can always return to your home directory by typing cd ~. How can you tell if it worked? Try pwd.

mkdir Make directory

 You can create new sub-directories within your directories with the mkdir command. Use cd to get to the directory within which you would like to have a sub-directory, then type mkdir name where name is the name youwould like to give the sub-directory. You can upper or lower case letters, dashes, and dots, but you cannot have any spaces in the name.
 
 

chmod Change file modes

 Whenever you create a new file or directory, or move a file to a directory, it is given certain rights. Generally, it is set so that only you can read or alter the contents of the file. When we publish files on the Web we obviously want other people to be able to read the contents of the file. To make this possible we use the chmod command. For purposes of publishing on the web you will need to know two variations of this command: chmod 755 dirname and chmod 644 filename. These varations apply to directories and files, respectively. 

Permissions or rights to files and directories can be set for three different groups of people: you the owner, a predetermined specified group of people, or everyone in the world. The rights that can be set are read rights (the file can be read but not altered or deleted), write rights (the file can be altered or deleted) and execute rights which apply to programs or directories. In the case of directories, this simply means that you can get into the directory. 

For web pages we need to set rights for both directories and files. We want to set the rights so that we, as owners, can get into our directories and add or make changes to the files in them. We want other people to be able to get into the directories and read the files, but not be able to make any changes to them. Thus, as owners, we want full read and write rights to our files and write and execute rights to our directories. But we want visitors to have only read rights to our files and execute rights to our directories (they can see them but not make changes). 

The UNIX chmod command gives us the means to control these rights. When we set a file using chmod 644 we are telling UNIX to give that file read and write permissions for the owner and read-only permissions for everyone else. When we use chmod 755 we are telling UNIX to give the owner full rights to the directory but only execute rights to everyone else. Why those numbers? To find out you may wish to read Wesley Wright's explanation.

 So, you will need to use the chmod command on your web files. You can do this directly at the prompt when you have logged in to zoo. But be careful! Know where you are. If you wish to set rights for a directory, the easiest was is to be in the directory just above it. That is, if you have a sub-directory named "mystuff" in your public_html directory, first change to the publis_html directory, then issue the command: chmod 755 mystuff.

 If you wish to set the rights for a specific file, change to the directory where that file is and type: chmod 644 filename (where filename is, of course, the name of the file you wish to chmod). 

Windows and Macintosh FTP users: You do not have to login to zoo to use the chmod command. Your FTP program lets you use chmod while FTPing. More information on that can be found in the Windows and Mac Tutorials in the section on FTPing.

 

cp copy

To make a copy of a file, type:
cp oldfilename newfilename

You can also copy the file to a new file in a different directory:
cp oldfilename dirname/newfilename (copies the file to a new file in a subdirectory)
cp oldfilename ../newfilename (copies the file to the directory one level above this directory)
cp oldfilename ../dirname/newfilename (copies the file to a directory that is a subdirectory of the level above the current one)

mv move

To move a file from one location to another, or to change its name.

mv oldfilename newfilename

You can also move files from one directory to another in the same way as the copy command, above.

del delete  (USE WITH CARE!)

To delete files, type:

del filename

To delete multiple files, use an * asterisk as a wild card:

del *  (watch out! This will delete all the files in the current directory!)
del *.html  (delete all .html files in the current directory)
del c*  (delete all files in the current directory that begin with lower case c)

rmdir remove directory

To remove a directory. First change to the directory using the cd command. Next, delete all the files in the directory, then chnage to the directory one level above this one and remove the directory. For example, if I have a directory in the public_html directory named "temp" that has several files in it, to delete the files and the "temp" directory I would login to zoo and type:

cd public_html/temp  (to get to the temp directory)
del *  (to delete all the files in the temp directory)
cd .. (to move back up to the public_html directory)
rmdir temp  (to delete the temp directory)

man manual pages

 You can learn more about any of these commands by typing man command (where command is the name of the command) at your prompt. For example, to learn more about the ls command, type: man ls

 Beware: the man pages are meant as reference pages. That is, they are not written with ease of use and new UNIX learners in mind. This is a nice way of saying they can be rather intimidating!
 

There are also many books about UNIX available at the UVM store or local bookstores. You should be aware that there are many "flavors" of UNIX. While they all behave similarly there are some differences. Zoo/moose use the variation known as AIX.


Created by Hope Greenberg. Last update: 10/31/2001