MTC logo MTC logo Midlands Technical College
Prospective StudentsEnrolled StudentsFaculty & StaffCommunity Partners
About
Academics
Continuing Education
Distance Learning
Student Forms
Library
Class Schedule
News & Updates
Calendar
Directory
Site Map
Ask MTC
MTC Jobs Bookstore
Home
navigation
 
Search

 

About MTC Academics Continuing Education Distance Learning Student Forms Library Class Schedule News & Updates Calendar Directory Site Map Ask MTC MTC Jobs Bookstore Home


CPT 247


Quick Reference

Exercise

Shellscript1

 

UNIX Command Quick Reference

The following is a simple reference to several commands available in UNIX. The following is not a complete list of the command set of UNIX and some commands, if used improperly could render your system unusable.

 

File Manipulation

Action                                     Command             Example

append to a file            cat                  cat thisfile >> tothisone
combine two files         cat                  cat thisfile1 thisfile2  > tothisone
copy files                      cp                   cp thisfile tothisone
create a file                  cat                  cat > newfile
create a file                  touch              touch newfile
list file contents           cat                  cat thisfile
list file contents           pg                   pg thisfile
list file contents           more              more thisfile
list file contents - last lines   tail       tail thisfile
list file contents -
last 50 lines tail       tail -s 50 thisfile
move a file                   mv                  mv thisfile /usr/home/tohere
remove a file - erase   rm                  rm junkfile
print file - System V    lp                    lp thisfile
print file - BSD            lpr                  lpr thisfile
print file                        pr                   pr thisfile

 

Directory Navigation & Manipulation

Action                                      Command             Example

change directories       cd                   cd /usr/home/merwin
change directories -
up 1 level   cd        cd ..
change directories -
jump home   cd        cd
create a directory        mkdir             mkdir /usr/home/merwin/newdir
path location                pwd                pwd
remove a directory      rmdir              rmdir /usr/home/merwin/junkdir
directory listing - simple       ls         ls
directory listing - long           ls         ls -l
directory listing - all/long      ls         ls -la

 

Miscellaneous

Action                                                          Command             Example

change password                                          passwd            passwd
list processes - owner                      ps                   ps
list processes - everyone                ps        ps -e
list processes - username               ps        ps -fu username
change access privileges               chmod     see below
change ownership                        chown            see below
who else is logged on                   who                who
who owns this session                     who                who am i

 

Change Access Modes - chmod

There are several combinations of options available with chmod.

chmod XXX filename  or   chmod XXX /usr/home/directoryname

Position of X effects:

X00 - owner privileges

0X0 - group privileges

00X - world or other privileges

 

The value of X can be:

0 - no privileges

1 - execute

2 - write

3 - write/execute

4 - read

5 - read/execute

6 - read/write

7 - read/write/execute

 

Action                                                                    Command             Example

read/write - owner,group                    chmod     chmod 660 filename

read/write/execute - owner,group      chmod     chmod 770 filename

read - owner, group, world                 chmod     chmod 444 filename

 

Change Ownership - chown

There are several combinations of options available with chown.

chown owner.group  filename  or   chown user.group directoryname

Substitute owner.group with the name of a owner and/or a group that exists on the system.

Action                                                                    Command             Example

set owner=merwin - file                     chown      chown merwin thisfile
set owner=oracle.dba - file                chown      chown oracle.dba controlfile3.ctl
set owner=oracle.dba - file/all           chown      chown oracle.dba *
set owner=oracle.dba - directory      chown      chown oracle.dba /oracle_home

 

VI Quick Reference

The following is provided to help you with VI, a text editor available for numerous operating systems. The following is not a complete list of the command set or the macro language available in VI.

 

Cursor Movement

h or [BkSpc]  Character Left

j or +              Line Down

k or -              Line UP

1 or [SPACE]...................................... One Character Right

$                     Go to End Of Line

)                     Next Sentence

(                     Previous Sentence

}                     Next Paragraph

{                     Previous Paragraph

^                    Start Of Line

w                    Next Word

b                     Previous Word

e                     End of Word

nG                 Go to Line n

 

Changing Text

r                     Change Character

R                    Replace Mode

cw                  Change Word

cc                   Change Line

C                    Change to End Of Line

 

Deleting Text

dw                  Delete Word

dd                   Delete Line

D                    Delete to End Of Line

u                     Undo Last Delete

x                     Delete Character

X                    Destructive Backspace

 

Inserting Text

a                     Insert After Cursor

A                    Append To EOL

i                      Insert Before Cursor

I                     Insert At Start Of Line

o                     Open New Line Below

O                    Open New Line Above

[ESC]             Terminate Insert

 

Screen Control

[CTRL] [d]     Half Screen Down

[CTRL] [u]     Half Screen Up

[CTRL] [f]      Full Screen Down

[CTRL] [b]     Full Screen Up

[CTRL] [l]      Redraw Screen

 

Searching Text

/pattern[CR]   Search Forwards

/[CR]               Repeat Search

?pattern[CR]              Search Backwards

?[CR]              Repeat Search

 

Saving / Exiting

:wq or ZZ       Save & Exit

:q!                  Quite, No Save

:w filename   Save Text as filename