A Brief Introduction To

basic
UNIX
commands

by Robert Evans
April 6, 1994

 

 

SOME USEFUL UNIX COMMANDS

 

(1) pine

Send/Receive mail messages & files

(2) talk

Simultaneously chat with another UNIX user

(3) ftp

File transfer utility

(4) vi

Visual Editor, create & modify text files

(5) more

View a text file one screen at a time

(6) nn

Read USENET News Groups

(7) ls

List files in a directory

(8) mkdir

Make a directory

(9) rmdir

Remove a directory

(10) cd

Change directory

(11) man

Get full documentation for any UNIX command

(12) passwd

Change your password

(13) finger

Get information about a computer user

(14) apropos

Get help regarding a general keyword

(15) clear

Clear the screen

(16) alias

Give a UNIX command a new name

(17) rm

Delete a file

 

 

(1) Pine - send/recieve mail

Usage: pine [address]

To enter pine and see a menu listing of all your mail messages, type, pine.

Once in the pine mail program, use the arrow keys to position the highlight on the mail message you want to read, and press ENTER.

To perform one of the following commands on a mail message in your mailbox, place the highlight on the message. When sending, forwarding, or editing a mail message, you will be placed in the "vi" editor. See the section on the vi editor for more details.

r

reply to the current message

b

bounce the current message to another address

f

forward this message to someone else

c

compose a new message

s

save the current message to a folder (type a file name over the suggested file name)

d

delete the current message

enter

read the current message

i

return to the message index

l

view folder listing

q

quit the pine mail program

 

 

 

(2) Talk - chat with other UNIX users

Usage: talk login@unixmachine

To talk to evansrf@omni.cc.purdue.edu, type the following and wait for connection:

talk evansrf@omni.cc.purdue.edu <enter>

If the user is not logged on, no connection will be established.

 

 

(3) ftp - file transfer utility

Usage: ftp machineName

To connect to omni.cc.purdue.edu using an anonymous connection, type:

ftp omni.cc.purdue.edu

When asked for a login, type, "anonymous". When asked for a password, type your login@address.

While connected to a host machine using ftp, the following commands may be used:

ls

View directory (brief listing)

dir

View directory (long listing)

cd <dir>

Change directory

get <file>

Get a file

put <file>

Send a file

binary

Xfer files as binary files

ascii

Xfer files as text files

bye

Exit ftp program

CTRL-D

Exit ftp program

(4) vi -- Visual Editor, create & modify text files

Usage: vi [filename]

The following simple commands and keys control the vi editor.

It is important for "vi" users to understand that there are TWO modes used by vi, and that vi is in one of these TWO MODES at all times. The modes are:

Edit mode: Perform editing functions on pre-existing text.

Insert mode: Insert new text into the current document.

Please note: Whenever you are in insert mode, you must hit ESC to leave Insert mode before Edit mode commands will work. This will become a habit quickly. NOTE: Vi starts in EDIT mode.

Insert Mode Commands (these commands put you into insert mode for typing text):

i

Insert before current character (ESC to stop inserting)

A

Insert after last character of current line (ESC to stop inserting)

a

Insert after current character (ESC to stop inserting)

o

Open a blank line below current line (ESC to stop inserting)

O

Open a blank line above current line (ESC to stop inserting)

R

Overwrite characters (ESC to stop overwriting)

r

Replace one character

Backspace

Back up and delete the previous character

ESC

Exit Insert mode, and enter Edit Mode

 

Edit Mode Commands (these commands manipulate existing text only):

h

Move left

l

Move right

j

Move down

k

Move up

dd

Delete a line

10dd

Delete 10 lines

u

Undo the last major command

x

Delete one character

1G

Goto line number 1

G

Goto last line

0

Goto first charatcer of current line

$

Goto last charatcer of current line

:w <name>

Write current file with new name

:r <name>

Put contents of a file into file being edited

:wq

Exit vi and save the current file

ZZ

Exit vi and save the current file

 

 

(5) more -- view a text file one screen at a time

Usage: more <filename>

To view a file called letter1 type:

more letter1 <enter>

 

(6) nn -- Net News -- read world wide News Groups

Usage: nn [group_name]

To read news groups, simply type nn and press enter. Once the Net News main menu appears, you can press the question mark (?) at any time for help. Read the help carefully for the many commands available (or read the man page for nn).

NN basic commands:

G

Go to a specific news group.

N

Goto next newsgroup

:post

Post a messge to the current or a new group. You will be asked for a group name. If you want to browse a list of group names, press the question mark(?). If you want to cancel you post request, simply press return twice without giving a name or a subject.

Z

read selected messages

Space Bar

See next screen of available messages

~~

Unselect all messages in current group

Q

quit

 

 

(7) ls -- list files in a directory

Usage: ls [option]

To list the files in the current directory type:

ls

<enter>

Options include:

-l

== long listing with filesizes, etc

-a

== show all files including hidden files

-F

== precede directories with a slash

To see a long listing of all files including hidden files type:

ls -al

<enter>

 

 

(8) mkdir -- make a directory

Usage: mkdir <directory>

To make a directory called misc type:

mkdir misc

<enter>

 

 

 

(9) rmdir -- remove a directory

Usage: rmdir <directory>

To remove a directory called misc type:

rmdir misc

<enter>

 

 

(10) cd -- change directory

Usage: cd <directory>

To change from the current directory to a directory called misc type:

cd misc <enter>

To change to your root (or home) directory, type:

cd <enter>

To back up one directory, type:

cd .. <enter>

 

 

(11) man -- get full documentation for any UNIX command

Usage: man <command>

Use this command to find out more information regarding ANY UNIX command you are using or would like to use!!! Very helpful at times.

To see the documentation for the ls command, type:

man ls <enter>

To see documentation for the vi command, type:

man vi <enter>

 

 

(12) passwd -- change your password

Usage: passwd

To change your password, simply type:

passwd <enter>

Note: A valid password must be from 6 to 8 characters long, and can not be a word found in the dictionary. Use two or three small words run together with mixed upper and lower case letters, and/or some numbers.

 

(13) finger -- get information about a computer user

Usage: finger <user@machine>

Use this command to find out information about a person who has a computer account either on your machine, or on another machine. Information you can get may include: whether or not the person is logged on, office numbers, telephone numbers, last time their mail was read, last time the user logged on, from where the user is logged on, etc. Try it, you'll like it.

To get information about evansrf@omni.cc, type:

finger evansrf@omni.cc <enter>

To get information about evansrf@vm.cc.purdue.edu, type:

finger evansrf@vm.cc.purdue.edu

To get information about everyone who is currently logged on to the machine called vm.cc.purdue.edu type:

finger @vm.cc.purdue.edu

 

 

(14) apropos -- get help regarding a general keyword

Usage: apropos <keyword>

Use this command to see a list of commands related to a certain command or keyword. A very helpful command.

To see a list of commands related to editing, type:

apropos edit <enter>

To see a list of commands related to kermit, type:

apropos kermit <enter>

If there is a command of interest in the list that is generated, you can get more information about it by using the man command.

 

 

(15) clear -- clear the screen

Usage: clear

To clear the screen, simply type:

clear <enter>

 

 

(16) alias -- give a UNIX command a new name

Usage: alias <newcommand> <oldcommand>

Use this command to rename UNIX commands with names that are more familiar to you.

To create a command called dir (like the DOS dir command) which actually performs the UNIX

ls -lF command, type:

alias dir "ls -lF"

To create a command that does the above AND clears the screen first, type:

alias dir "clear; ls -lF"

A common use for this command is to place it in a file called .cshrc (note the dot preceding the name. Any file beginning with a dot is a hidden file). .cshrc file is automatically executed each time you log into your account. By placing a series of alias commands in this file, your account will be automatically configured to your liking. It is possible to replicate nearly every MS DOS command using alias.

 

 

(17) rm -- Delete a file

Usage: rm <filename.ext>

To delete a file called myfile.doc, type:

rm myfile.doc

To delete all files the the extension .doc, type:

rm *.doc