|
Introductory Information about
Unix
Unix is a computer operating system, like DOS for IBM PCs. An operating
system consists of commands that let you manage information in the form of
files, or run programs that perform tasks such as word processing, e-mail, or
data analysis.
A Unix file is a collection of information stored on disk, be it the text of
a document, data for statistical analysis, or the executable code for a program.
A file is referenced by a name. A filename in Unix can consist of any
combination of characters on the keyboard except for the space bar and all of
the following: * ? ! | \ / ' " { } < > ; , ^ ( ) $ ~. These
characters cannot be used in filenames because they have special meaning to the
shell. For example, the first two symbols are used as "wildcard" characters when
you're issuing commands: the * will match any string of characters in a
filename, whereas the ? matches any single character.
How to Issue Commands in Unix
The Unix environment is interactive. When you type a command at the keyboard
and then press the Enter or Return key, Unix immediately begins to
act on the command. More accurately, Unix interprets the command using a special
program of its own called the shell. All shells produce a shell prompt to let you know that Unix is
awaiting your next command. Whenever you see this prompt, you
know that the Unix shell is ready for your next command.
Unix is case-sensitive. That is, Unix distinguishes between upper and
lower case letters in the names of files and programs. Thus, while ls is
a valid Unix command, LS is not. Login names and passwords are also
case-sensitive.
Some programs, such as Pico, have their own commands that you type within the
program rather than at the Unix shell prompt. However, the shell prompt
reappears whenever you exit such programs.
For more information, see Getting
Started in Unix (Sweet Hall, second floor, document racks), or phone a
consultant at 725-2101.
Basic File
Commands: These are typed at the shell prompt host:~>.
|
ls |
List the files in the current directory
|
|
ls-a |
List all the files in the current directory, even the hidden
ones |
|
ls -F |
As above, but indicate sub-directories by appending a
backslash (/) to their name |
|
cp FILE1 FILE2 |
Make a copy of FILE1 and call the copy FILE2 |
|
mv FILE1 FILE2 |
Rename a file from old name FILE1 to new name FILE2
|
|
mv FILE1 DIR/ |
Move a file from it's present directory into another
directory (DIR) |
|
rm FILE |
Remove or delete FILE |
|
more FILE |
Display the contents of FILE, pausing after each screenful
|
--More--(18%) Whenever you see something like the above at the
bottom of your screen, you can:
|
press the space bar |
To see the next screenful of text |
|
type b |
To go back one screenful |
|
type q |
To quit the listing of text and return to the Unix shell
prompt |
Correcting Typing Mistakes:
(at the Shell Prompt)
|
Delete or Backspace |
Erase the last character you typed |
|
Ctrl-u |
Delete the last line you typed |
Basic Directory Commands:
These are typed at the shell prompt host:~>. In Unix your files are organized in
directories and subdirectories. When you first log in to your account, you are
placed in your home directory, which you can refer to with the character ~.
|
cd DIR |
Go to the directory called DIR |
|
cd .. |
Go to the directory above the current directory
|
|
mkdir DIR |
Create a new directory called DIR |
|
rmdir DIR |
Remove the directory DIR (must be empty first; if not, use
rmdir -R |
|
cd or cd ~ |
Go to your home directory |
|
mv DIR1 DIR2 |
Move or rename a directory from old name DIR1 to new name
DIR2 |
Use the / character to separate directory and file
names when specifying a path.
Printing You
can print Unix files and mail messages to both your own printer and a network
printer. The latter is easier but requires that you walk to the network printer
to pick up your output.
Printing On a
Sweet Hall Printer To print a Unix text or PostScript file, type
the following command at the system prompt:
lpr -PNAME FILE ->
where NAME is the name of the printer, e.g., sweet0.
Printing to Your
Own Printer To print a Unix file on your own printer, you must
first "download" it to your desktop computer. Exactly how you do this depends on
which communication package you use, as well as which type of computer you have.
These instructions apply only to IBM PCs (and compatibles) that are running
under DOS, are linked to SUNet via Ethernet, and have the ftp protocol
installed.
At the DOS prompt (assumed here to be C:\>), enter:
|
C:\> ftp HOSTNAME |
Connects your PC to HOSTNAME |
|
(username) userid |
Your account on the host |
|
Password: xxxxxx |
Replace xxxxxx with your password |
|
ftp> cd DIRECTORY |
Change to DIRECTORY |
|
ftp> get FILENAME |
Copies FILENAME to PC |
|
ftp> quit |
Exit ftp and go to DOS |
|
C:\> copy FILENAME lpt1 |
Prints FILENAME on lpt1 |
Useful
Commands
|
exit |
Ends your work on the Unix system |
|
Ctrl-l or clear |
Clears the screen |
|
Ctrl-c |
Stops the program currently running |
|
Ctrl-p |
Retrieves the last shell command you typed |
|
Ctrl-z |
Pauses the currently running program |
|
man COMMAND |
Looks up the Unix command COMMAND in the online manual pages
|
|
find . -name FILE -print |
Finds all paths containing FILE in the current directory or
below it |
|
fgrep -i PATTERN FILE |
Searches for and displays all lines in file that contain
PATTERN (case insensitive) |
|
finger USER@ADDRESS |
Displays login/e-mail status of a user at another host
|
|
jobs |
Lists background jobs started during your current login
session |
|
ps |
Lists all jobs (background and foreground) started during
your login session |
|
du |
Displays disk usage in kbytes by directory, starting in the
current directory and working down |
|
du -s |
Displays total disk usage |
|
fs listquota |
Displays your current disk space usage and quota in kbytes
|
|
telnet ADDRESS |
Logs on to another machine on the Internet on which you have
an account |
|
ftp ADDRESS |
Begins a file transfer session with another computer on the
Internet |
|
wc FILE |
Counts the lines, words, and characters in FILE
|
|
spell FILE |
Reports possible misspelled words in FILE |
|
webster WORD | more |
Looks up a word via the online version of Webster's
dictionary |
Unix Shell Short
Cuts
The Unix shell keeps a record of the commands you type
during your login session. Here are a few commands that take advantage of this
history facility. All are typed at the shell prompt host:~>.
|
history |
List all commands typed so far (default maximum number=20)
|
|
!! |
Repeat the last command |
|
!n |
Repeat command n from the history list |
|
!PATTERN |
Repeat last command beginning with PATTERN |
|
^PATTERN1^PATTERN2 |
Repeat last command but replace PATTERN1 (usually a typo)
with PATTERN2 (the correction) |
|