BASIC UNIX COMMANDS

You must first logon to a UNIX machine. The method(s) to do this vary, so check with the facility you are at on how to logon. Once logged on, these commands are essential to learn. More information about them (and other commands) can be obtained by entering man command (short for manual). For example, to obtain a manual about the command cat, you would type man cat. cat - List a file USAGE: cat [ -n ] file... OPTIONS: -n display line numbers. EXAMPLES: cat myprog.c cat -n myprog.c cd - Change directory USAGE: cd [ directory ] EXAMPLES: cd cd mysource NOTE: The command cd with no arguments will take you to your home directory ( i.e. the directory you start in when you first login to the system ). The command cd .. will take you to the directory above the one you are in. cp - Copy a file USAGE: EXAMPLE: NOTE: cp file1 file2 cp file1 ...directory cp myprog.c myprog.1.save Suppose your instructor tells you to get a copy of the file firstprog.p that is in the directory /u/mathcs/fs/wilma. The complete command to copy this file to the directory you are in is: cp /u/mathcs/fs/wilma/firstprog.p firstprog.p It is important to note that the forward slash "/" is used to specify path names.

logout - Exit unix USAGE: NOTE: logout Where you are returned to when you logout is depending on the method used to login to the unix system. If you try to logout and you get an error message “there are stopped jobs”, then type a fg command to go back to that job, then you can properly exit the session and logout.

lpr - Send a job to the printer USAGE: EXAMPLE: lpr [-J -C] filename lpr -J name -C WALAB_xx filename name is 1-8 character ID xx is a bin number The pr command formats and prints the contents of a file.
STUDENT TECHNOLOGY SERVICE CENTER 12/03/98

NOTE:

[ \\hermes\user\WALAB\LABDOCS\User Guides\BEG_UNIX.DOC]

Page 1 of 3

BASIC UNIX COMMANDS

ls - List the contents of the current directory USAGE: ls [ file1... ] EXAMPLES: ls ls *.exe (this lists only files that end with the extension .exe) ls pkzip.* (this lists only files that begin with pkzip and has any extension) mkdir - Create a new directory USAGE: EXAMPLE: more - List a long file USAGE: more file ... EXAMPLES: more myprog.c more a.c b.c c.c NOTE: You can also use this with other unix commands that involves listing data. EXAMPLES: finger |more cat file |more mv - Rename or move a file USAGE: EXAMPLE: mv file1 file2 mv file1 ... directory mv a.out myfirst mkdir directory... mkdir junkdir

passwd - Change login passwd USAGE: NOTE: passwd As you type in the passwords, the characters are not displayed on the screen.

pwd - Display the current directory USAGE: NOTE: rm - Remove file(s) USAGE: EXAMPLE: rm file... rm myfirst.old pwd pwd tells you which directory you are in.

rmdir - Remove an empty directory USAGE: EXAMPLE: NOTE: rmdir directory ... rmdir junkdir In order to remove a directory that contains files, you must first remove the files with rm and then remove the directory with rmdir.

[ \\hermes\user\WALAB\LABDOCS\User Guides\BEG_UNIX.DOC]

STUDENT TECHNOLOGY SERVICE CENTER

12/03/98

Page 2 of 3

BASIC UNIX COMMANDS finger - display information about local and remote users. USAGE: NOTE: finger If you use this command followed by a user’ login name, it will give some information s about that’ user’ account; directory route, last time he or she logged in, etc. s s finger user... finger stsc

USAGE: EXAMPLE:

who - Identifies who is currently logged on the unix machine, but displays less information than with the “finger” command. USAGE: who

spell - It checks your documents for spelling errors using an online dictionary. USAGE: EXAMPLE: spell file spell commands.txt

pine - Starts up the “pine” mailing menu. USAGE: NOTE: pine This program allows you to organize your e-mail, plus has other unique features that the Regular mailing system doesn’ provide. You can also pick up a user guide for t “pine” as well.

[ \\hermes\user\WALAB\LABDOCS\User Guides\BEG_UNIX.DOC]

STUDENT TECHNOLOGY SERVICE CENTER

12/03/98

Page 3 of 3