Computer Labratories : Unix Introduction & Quick Reference
A few features to get you started with UNIX are described below.
Files are created by various UNIX commands. You can save your mail messages in files. You can also create text files with an editor.
Files are located in directories . Directories can contain other directories, which are called subdirectories . The directory containing a subdirectory is known as the parent of the subdirectory. Each account has a main directory known as its home directory .
%
ls
and then press the <Return> key. The
ls
command lists the names of files in the current directory.
The mkdir command is used to create directories. For example,
%
mkdir letters
creates a directory named
letters
.
Basic file manipulation commands include mv for moving or renaming files, cp for copying files, lpr for printing files, and rm for removing files. The cd command is used to change from one directory to another. For example, the command
%
cd letters
moves you to the
letters
subdirectory, and
%
cd
moves you to your home directory.
%
ls let*
will list all of your files in the current directory beginning with "let" and
%
ls *old
will list all files ending with "old".
A question mark is used to match any single character; for example,
%
ls ab?de
will match and list files named "
ablde
," "
abcde
," and "
ab.de
," but will not match files named "
abde
" or "
abccde
".
%
who > save_who
writes the output of
who
into the file
save_who
. Redirection using (
>
) will not overwrite an existing file. To do that, use (
>!
):
%
who >! save_who
To append to the end of an existing file, use two redirection characters (
>>
) instead of one.
Output of one command may be used as input to another command by using the pipe ( | ) symbol. For example,
%
who | wc -l
shows how many users are logged in by using
wc -l
to count the lines in the output of who.
%
!35
repeats the command numbered 35. Also, you can repeat the last command that began with "str" by typing the following:
%
!str
You can repeat the last executed command in the list by typing:
%
!!
%
apropos
topic
to find manual entries relating to "topic," and
%
man
command
to find the manual entry for "command".
Many introductory books on UNIX are available in bookstores and libraries.
| Basic File Commands: | |||
|---|---|---|---|
| cat | concatenate or display files | cp | copy files |
| ls | list file names | ls -l | list file names, sizes, attributes |
| mv | move or rename files | rm | remove files |
| Other File Commands: | |||
| diff | compare two files | fmt | simple line adjuster for mail |
| head | display the first ten lines of a file | tail | display the last ten lines of a file |
| less | display file one screen at a time | more | display file one screen at a time |
| grep | scan a file for a pattern | sort | sort/merge utility |
| wc | count lines, words, characters in file | wc -l | count lines in file |
| Commands: | |||
| cd | change to a different directory | mkdir | make a directory |
| pwd | print the current directory's name | rm | remove a file |
| rmdir | remove empty directory | rm -r | remove a directory and all files in that directory |
| Information Applications: | |||
| apropos | locate commands by keyword | man | display entries from the online manual |
| Controlling Applications: | |||
| fg | restart a suspended command | jobs | display suspended jobs |
| kill | kill a command | ps | display commands with process numbers |
| ^c | interrupt currently running process | ^z | suspend currently running process |
| ^s | stop output on screen | ^q | continue output on screen |
| Miscellaneous: | |||
| chfn | change information shown by finger | clear | clear screen |
| date | display date and time | finger | show information about users |
| lpr | send file to printer | passwd | change password |
| who | tell who is logged in | whatis | one-line description of a command |
| look | give correct spelling for words beginning with given word-part | ||
| spell | obtain list of misspelled words in a file | ispell | interactive spell checker |
| history | list most recent shell commands | logout | log out from a UNIX session |
| pico, vi, jove, emacs | edit a file | pine, mail, Mail | read/send email |
Last modified: October 6, 1996