Psychology 7291, Multivariate Statistics (Carey, 01-15-03)

Introduction to the UNIX Operating System

           

We will be using the Samiam in the workstation laboratory on the third floor of Muenzinger. This workstation uses the UNIX operating system. The following table gives some basic UNIX commands and their functions. UNIX commands as well as unix filenames are case sensitive (i.e., UNIX interprets a command in lowercase letters different from the same command in uppercase letters). An example of a UNIX command is

rm -i myfile

and general form of a UNIX command is

commandname -options arguments

The dash (-) is important because it separates the options of the command from the argument.  The above example will execute the remove command (rm) which deletes a file, using the i option (which prompts the user about whether the file should really be deleted), and operating on the file called myfile. As a general convention, UNIX commands will be given in bold, options in regular text, and arguments in italics.

 

Command
Function

man

Help. man commandname gives help for commandname; for example, man ls gives help for the command ls. An important command is man man which gives help on using the manual.

mv

Moves or renames a file. For example, mv myfile yourfile changes the name of file myfile to yourfile.

cp

Copy a file, For example, cp myfile yourfile makes a copy of myfile named yourfile.

cd

Change directory. For example, cd p7291dir changes from the current directory to directory p7291dir. To change to the higher directory in your hierarchy, enter the command cd .. (i.e., cd followed by two periods). For example suppose you were in the directory smith/p7291dir. Entering cd .. will place you in the directory smith. Entering cd with no arguments returns you to your root directory.

cat

Concatenates files to the screen. For example, cat myfile will list the contents of myfile. The cat command may also be used to copy files. For example, cat myfile > yourfile copies myfile to yourfile and cat file1 file2 > file3 copies file1, then appends file2 to file 3. When you want to display a file to the screen, use cat for only short files because it will print the entire file to the terminal without stopping. For longer files, use the command less (see below).

rm

Deletes or removes a file. For example, rm myfile deletes file myfile.

mkdir

Create a directory. For example, mkdir p7291dir creates directory p7291dir.

rmdir

Removes or deletes a directory.  For example, rmdir p7291dir deletes directory p7291dir. The directory must not contain any files.

ls

List the files in a directory. Use ls -a to list all files, including those hidden files that begin with a period (.). A star (*) serves as a wildcard. For example, ls *.sas lists all files that end in .sas, and ls *sas* lists all files than contain sas in the filename.

less

Display a file at a terminal one screenfull at a time. For example, less myfile displays file myfile one page at a time. After a page is displayed, enter return to list one additional line. Pressing spacebar will display the entire next page. Entering a b moves one page backwards.   Entering a q (for quit) stops the less processor and places you back into unix.  Entering an h gives help for the commands used by less.

logout

Logout from the current UNIX system. As a matter of courtesy, please always do this when you are finished with your session.

lpr

Prints a file; e.g., lpr myfile prints the contents of myfile. Use the enscript command below to save paper.

pwd

Display the present working directory, the directory that you are currently working in.

history

Displays a page of the previous unix commands that you have entered.  Each command as a number associated with it.  Entering an exclamation point followed by a number re-executes that command.  For example, !92 executes the 92nd command that you entered.

who

Shows the users who are currently logged on to the computer.

enscript

Use the command enscript &endash;2rGZ filename to print 4 pages on one physical page.

chmod

Changes the read, write, and execute permissions for your files.  With the exception of a few files such as the email you send and receive, anybody can read the contents of your files.  However, no one can write to your files without special permission.  The chmod commands changes these defaults.  For example, chmod o-r myfile changes the permission on myfile so that others cannot read the contents of myfile.  Use man chmod to obtain more information about this command.