Chapter 3. Using the Command Line

Table of Contents

Interacting with UNIX from the Command Line
Changing your password
Files and File Commands
File Names
What are Directories?
File Suffixes
Using Wildcard Characters in Filenames
Copying Files
Listing Files in Your Directory
Displaying the Information in a File
Removing Files
Using Directories
Making a New Directory
Moving Between Directories
Moving or Renaming a File
What is My Current Working Directory?
Using Pathnames
Reading the Online Manual Pages
Printing Files
Printer Names
Checking a Printer Queue
Removing Requests from a Printer Queue
Other Unix Commands
Grep - Searching a File for a String
How Much Disk Space Am I Using?
Changing Permissions on a File
Some Useful Features of UNIX
Using History of Your Commands
Changing Dot Files
Creating Your Own Command Aliases
Redirecting Input and Output
Background Processes
Pipes and Filters
A Brief Summary of some UNIX commands

Interacting with UNIX from the Command Line

When UNIX is waiting for the user to enter a command, it displays what we call the UNIX prompt. The prompt is a sequence of characters on the video display (possibly a shell window) which is really a request from the operating system to the user to enter another command. A typical UNIX prompt could be

algol{~}% _

When you look at your screen, you will see the name algol replaced by the name of the machine (or host) you are using. The value between the braces ({}) is the directory that you're currently in. The tilda (~) means that you are in your home directory. When a prompt appears on the screen you will also see an insertion point one space past the % sign. When you type a command this insertion point is where the characters will appear (the ‘_’ represents the insertion point. For example:

algol{~}% date_

To issue a date command, you press the Return key. If that were done in the previous example, you would see on your screen something similar to the following:

algol{~}% date
Mon Jul 26 09:58:44 EDT 2004
algol{~}%

Notice that the next prompt appears automatically when the last command has completed.

In UNIX, it is important to remember that the commands are usually in lower case letters. Therefore, ‘date’ works but ‘DATE’ does not! We say that UNIX is case sensitive. Try both ‘date’ and ‘DATE’.

hostname{~}% DATE
DATE: Command not found.
hostname{~}%

Some commands have options that are specified by a minus sign followed by characters. For example, ‘date’ may have the ‘-u’ option that displays universal time or Greenwich Mean Time.

hostname{~}% date -u

If you spell the command name correctly but supply an improper option, an improper argument or the wrong number of arguments, many of the commands will not give you an error message but only display a brief description of usage. The command assumes you mistyped something and need some assistance. Try an incorrect option for date and you will see an example of a usage message:

hostname{~}% date -p
date: illegal operation --p
usage: date [-u] mmddHHMM[[cc]y]
date [-u] [+format]
date -a [-]sss[.fff]

If you ever receive a ‘usage’ message, you typed something wrong. In a usage description, the square brackets ‘[ ]’ means that part is optional. Obviously from date's usage message, it allows several other features.