Tutorial: Unix - Introduction

Dr. Thomas E. Hicks
Computer Science Department
Trinity University
 


  1. General Definitions
  2. Login
  3. clear - Clear The Screen
  4. logout or exit - Exit The System
  5. passwd - yppasswd - Change The Password
  6. Valid File Names
  7. ls - Display File/Directory Listing
  8. vi - Universal VI Editor
  9. cat - Display Contents Of ASCII Text File
  10. cp - Copy A File
  11. mv - Move or Rename A File
  12. rm - Erase A File
  13. elm - Electronic Mail Program
  14. pine - Pine Mail Program
  15. lp - Print A File
  16. mkdir - Create A Directory/Folder
  17. rmdir - Delete A Directory/Folder
  18. cd - Change Directory
  19. man - Manual Help
  20. ctrl-c - Abort

General Definitions 
bit - short for binary digit - binary - either a 0 or a 1

byte - 8 bits - enough memory to store one character.

file - a collection of digital information (0's and 1's).

directory or folder - a special file used as a container in which to hold other files and/or directories. Directoies/Folders make it possible to manage and organize the thousands of files that reside on a computer system.

text file - ASCII file - a file of text information. Text files contain text in a traditional language such as English, Spanish, etc. Text files do not have the normal word processing features such as margin control, font selection, underscore, bold, etc. FORTRAN programs, C programs, and Pascal programs are examples of text files.

ASCII - American Standard Institute for Information Interchange - collating sequence to associate a seven bit character string with the more commonly used characters. A = 1000001 B = 1000010 C = 1000011

hardware - physical components of the computer and devices attached to the computer.

software - programs that make the machine complete some task. Word processors, spreadsheets, games, operating systems, and paint programs are examples of software applications.

operating system - a software program which controls the resources and processing of a computer. Common examples of operating systems are UNIX, DOS, Windows 3.1, Windows 95, Windows NT, and Macintosh Finder.

graphical user interface (GUI) - a graphical user interface is one which contains icons, pictures, and buttons to facilitate processing. Windows 95, Macintosh, Windows 3.1, and NT have an operating system with a graphical user interface. Some versions of UNIX also have a graphical user interface.

command line interface - terminal connections to UNIX systems run with a command line interface. The user enters strings of information on a line in order to direct processing and feed data. Mouse interactions such as drag & drop or copy & paste are not available on a command line interface.

editor - a software program used to create, display, and/or edit text files. Editors do not permit the normal word processing features such as margin control, font selection, underscore, bold, etc. vi is an example of one of the editors available on all UNIX platforms. Edit is an example of an editor available on all IBM DOS platforms. Simple Text is an example of an editor available on all Macintosh platforms.

word processor - a software program used to create, display, and/or edit document files. Today's powerful word processors enable the user to create documents which contain (1) margin choices, (2) font choices, (3) style choices [bold, underline, etc.], (3) color choices, (4) graphic insertion, etc. Dominant players in today's word processing market are Microsoft Word and Word Perfect.

computer program - a series of instructions that tell the computer hardware what to do. These instructions are generally written in a high level programming language such as C, C++, Pascal, FORTRAN, BASIC, PL/1, COBOL, Modula 2, Scheme, Lisp, APL, Java, Javascript, etc.

high level programming language - a formal language (often English-like) used by computer scientists to create instructions for the computer hardware. Examples of high level programming languages are C, C++, Pascal, FORTRAN, BASIC, PL/1, COBOL, Modula 2, Scheme, Lisp, APL, Java, Javascript, etc. The code below represents an ultra simple FORTRAN program, called Hello.f, which would print "Hello World" on the console display.

binary file or executable file - a collection machine language instructions that enable the computer to perform some function. Spreadsheet applications, such as Excel, Lotus, and Quatro are binary executable files. Word processors such as Word and Word Perfect are binary executable files. Paint programs such as Corel, PaintShop, and Paint are binary executable files. Other executable files include calculators, disk copy programs, calendars, operating systems, Netscape, ftp, Telnet, etc.

compiler - a computer program which converts high level instructions into binary machine language. Most UNIX systems have FORTRAN, C, and C++ compilers available.

Telnet program - A program used to provide a terminal interface with a central computing system. Telnet applications are available for almost every type of computer; there are several Telnet programs available for both the IBM PC and the Macintosh. Telnet applications can be used to connect the university lab machines to the central computer. Telnet applications can be used to connect home computers (via modem and phone lines) to the central computer. 

Login

Once Telnet is running, you will have to provide the name of the central computer you wish to access. Each Telnet application is slightly different!

For Example: students at Trinity University have accounts on 15 UNIX platforms. They may opt to use any of the following MachineNames [janus01.cs.trinity.edu, janus02.cs.trinity.edu, ... janus15.cs.trinity.edu]

For Example: Students at the University of Texas at San Antonio have an account on the MachineNamed runner.utexas.edu


In order to logon to a central computer with Telnet, you will generally have to provide both your username and your password. You should never tell others your password!

UserName = Generally constructed from the first letter of first name + up to seven letters of the last name
Thomas Hicks = thicks (all lower case)
Arthur Anderson = aanderso
Sally Smith = ssmith

Password = ____________
 


clear - Clear The Screen

clear <-- to clear the console window. 
 


logout or exit- Exit The System

logout - to logoff the computer
exit 
 


passwd - yppasswd - Change the Password

UNIX passwords are case sensitive! If the password is [DogSled], then [dogsled] will not work!

Although UNIX systems have some flexibility in password requirements, passwords must generally be at least six characters {A,B,C,...,Y,Z,a,b,c,...y,z,0,1,2,...,8,9, special characters (, . : ; + - etc.)}. If you use more than eight characters, only the first eight are significant. Some password systems require that you have at least one special character!

Hint! Pick a password that you can remember. Pick one that others will not be able to guess. With the exception of your faculty and systems administrators, do not ever tell anyone else your password!

To change the password on most UNIX systems:

passwd <Return>
Enter Old Password : XXXXXX
Enter New Password : YYYYYYYY
Re-enter New Password : YYYYYYYY

To change the password on UNIX systems with multiple systems that maintain a single password, you might have to use yppasswd. See Below!

yppasswd <Return>
Enter Old Password : XXXXXX
Enter New Password : YYYYYYYY
Re-enter New Password : YYYYYYYY

Students should immediately change their password to something they can remember! Should you forget your password, you will have to contact the systems people; it will generally take a couple of days to get your password problem resolved! 
 


Valid File Names

UNIX users will often select the names for their directories and files. Valid UNIX file/directory names may consist of one to seventeen characters from the set {A,B,C,...,Y,Z,a,b,c,...,y,z,0,1,2,...,8,9, Underscore(_),period(.)}

    The following would be valid directory/file names:
    123
    Hello.f
    GoodStuff.c
    Mail.BillHicks
    Correspondance
    FORTRAN
    C
    The following would be invalid directory/file names:
    Bill Hicks                   <-- Blank
    ABCDEFGHIJKLMNOPQRSTUVWXYZ   <-- Too long
    ONE/TWO                      <-- Invalid Character

Filenames that begin with a period (.) are considered to be hidden file names. UNIX systems often include special hidden files such as .profile, .login, .cshrc to assist in the user's setup. Do not erase any of your hidden files until you know what you are doing!
 


ls- Display File/Directory Listing


ls - to get a brief file display non-hidden files and directories)

ls -a -to get a brief file display of all files and directories
ls -l - to get a long file display of all non-hidden files and directories
ls -la - to get a long file display of all files and directories

ls He* - to get a brief file display of all non-hidden files and directories that begin with He . The * is a wild card that says "I don't care what the end of the file name may be".
ls *.f - to get a brief file display of all non-hidden files and directories that end with .f . The * is a wild card that says "I don't care what the beginning of the file name may be"
ls T*.f - to get a brief file display of all non-hidden files and directories that begin with T and end with .f . The * is a wild card that says "I don't care what the middle of the file name may be".
ls -la T*.f - to get a b long display of all files and directories that begin with T and end with .f . The * is a wild card that says "I don't care what the middle of the file name may be".

ls Prog??.c - to get a brief file display of all non-hidden files and directories that begin with Prog and end with .cand may have any characters for characters 4 and 6. The ? is a wild card that says "I don't care what this character of the file name may be". This would be a great way to list all thirteen of the C programs when you have a collection of programs called Prog01.c, Prog02.c, Prog03.c, Prog04.c, Prog05.c, .., Prog012.c, Prog013.c. 
 


vi- Universal VI Editor

vi Hello.f - to launch the vi editor with file Hello.f. If file Hello.f exists, the editor opens the file. If file Hello.f does not exit, the vi editor opens an empty file in preparation for that which you are about to enter. If you make a mistake on a line and have not hit the Return Key, you can use the backspace key to correct the mistake. If you make a mistake and hit the return key, don't try to correct it for the moment. Just keep typing!

    Try creating the Fortran program above by following the following directions:
    vi Hello.f   <Return>                             <-- launch the editor
                                                              <-- enter the input mode
    Program Hello  <Return>                      <-- type the program header line
    <Tab> Print*, 'Hello World'   <Return>   <-- type the program code
    End <Return>                                        <-- type the last line; don't forget the Return!
    <ESC>:wq                                             <-- exit the input mode, write the program to disk, and exit the editor 


cat - Display Contents Of ASCII Text File

cat Hello.f <-- to display the contents of the ASCII text file Hello.f in the console window.
cat .login <-- to display the contents of the ASCII text file .login in the console window.
cat Hello.f .login <-- to display the contents of file Hello.f followed by the contents of file .login
cat *.f <-- to display the contents of the ASCII text files that end in .f 
 


cp - Copy A File

cp Hello.f NewHello.f <-- to duplicate file Hello.f. The new copy will be called NewHello.f
cp a.out Hello <-- to duplicate the binary file a.out. The new copy will be called Hello 
 


mv - Move or Rename A File

mv Hello.f NewHello.f <-- to change the name of file Hello.f to be NewHello.f
mv a.out Hello <-- to change the name of file a.out to be Hello 
 


rm - Erase A File

rm Hello.f <-- to erase file Hello.f
rm a.out <-- to erase file a.out
rm a.out Hello.f <-- to erase file Hello.f and file a.out

rm *.f <-- to erase all of the files that end in .f
rm T*.f <-- to erase all of the files that begin with T and end in .f

rm -r Programs <-- to erase directory Programs and all of the files and directories contained therein!

Be very careful with remove. There is no recovery from mistakes! 


elm - Electronic Mail Program

elm <-- to launch the elm mail program 


pine - Pine Mail Program

pine <-- to launch the pine mail program 


lp - Print A File

lp Hello.f <-- to print a file called  Hello.f on the default printer.

Most UNIX systems are linked to many printers. In order to avoid accidental printing, many users are assigned no default printer.

lp -dStylus Hello.f <-- to print a file called  Hello.f on the printer called Stylus. 


mkdir - Create A Directory

mkdir Labs <-- create a directory/folder called  labs
mkdir Correspondance <-- create a directory/folder called  Correspondance
mkdir Samples <-- create a directory/folder called  Samples

Directories enable us to organize and manage the many files that accumulate on a computer. 


rmdir - Delete A Directory

rmdir Labs <-- remove an empty directory/folder called  labs
rmdir Correspondance <-- remove an empty directory/folder called  Correspondance
rmdir Samples <-- remove an empty directory/folder called  Samples

rmdir -r Samples <-- remove an directory/folder called  Samples and all files/directories contained therein.
rmdir -r Correspondance <-- remove an directory/folder called Correspondance and all files/directories contained therein. 


cd - Change Directory

The command line interface is always working in some folder/directory; this is generally referred to as the Current Directory, the Working Directory, or the Active Directory. Depending upon the UNIX shell and configuration, the user may be able to look at the prompt and determine the working directory.

Suppose my Active Directory is /users/thicks and my directory structure looks something like the following:

The root directory of Dr. Hicks (above) contains three directories/folders [Info, Mail, and Stuff] and one file [XYZ].

Folder Info contains two files [WP and SH]; the complete path to folder Info is /users/thicks/Info.

Folder Stuff contains one file [AB]; the complete path to folder Stuff is /users/thicks/Stuff.

Folder Mail contains one folder [Bill] and two files [Tim and Ann]; the complete path to folder Info is /users/thicks/Mail.

Folder Bill contains one file [Jan.1]; the complete path to folder Info is /users/thicks/Mail/Bill.

cd <-- No matter what the active directory, this changes the active directory to your root directory [/users/thicks]

cd Stuff <-- If /users/thicks is the active directory, this changes the active directory to /users/thicks/Stuff

cd mail <-- If /users/thicks is the active directory, this does nothing since there is not a directory mail within the active directory; file names are case sensitive!

cd Info <-- If /users/thicks is the active directory, this changes the active directory to /users/thicks/Info

cd Mail <-- If /users/thicks is the active directory, this changes the active directory to /users/thicks/Mail

cd Bill <-- If /users/thicks/Mail is the active directory, this changes the active directory to /users/thicks/Mail/Bill

cd .. <-- Takes you back one directory. If /users/thicks/Mail/Bill is the active directory, this changes the active directory to /users/thicks/Mail

cd .. <-- Takes you back one directory. If /users/thicks/Mail is the active directory, this changes the active directory to /users/thicks

cd /users/thicks/Bill <-- No matter what the active directory, this changes the active directory to /users/thicks/Bill 


man - Manual Help

man ls <-- launch the on-line help system and provide information about the various options available for the UNIX command ls

man cp <-- launch the on-line help system and provide information about the various options available for the UNIX command cp 


ctrl-c - Abort

When you wish to abort a program or application, holding down the control key [ctrl] and pressing the C key often works! 


Possible Exam/Quiz Questions - UNIX #A


May be accessed through URL: http://www.cs.trinity.edu/~thicks
May also be accessed through URL: http://carme.cs.trinity.edu
This Document May Not Be Printed or Reproduced Without Written Permission.
 2003 Copyright : Dr. Thomas E. Hicks
Permission granted : Professional Educators & College Students may print one copy of this page!

Dr. Thomas E. Hicks

Computer Science Department    
Trinity University

"Dr. Web"