Intro to Unix

Basic Commands

command meaning examples
ls list files in directory ls -l
ls -t
cp copy a file cp oldfile newfile
cp /home/units/comp225/pracs/bug0.cc .
copies bug0.cc to current directory
mv move a file mv oldfile newfile
mv prac.cc mypracs/prac.cc
rm remove or delete a file rm prac.cc
more display a file page by page more prac.cc
lpr print a file lpr prac.cc
lpq check printer queue lpq
lprm remove a job from printer queue lprm < jobno >
mkdir create a directory mkdir pracs
cd change directory cd pracs
cd        goto home directory
cd ..        goback 1 level
emacs edit a file using emacs emacs fred.cc
joe edit a file using joe joe fred.cc
quota -v show disk quota used/left quota -v
< control-d > logout
end-of-file

when reading from keyboard
< control-c > abort when desperate
< control-z > suspend suspend program - get back by fg
man manual entry man rm     get help on rm
man -k fred      keyword search of manual for fred
pine for email pine
passwd to change password it will prompt you for old password and then new one twice

Some More Useful Commands

command meaning example
wc file word count of file wc fred.cc
grep string file find string in file grep cerr *.cc
w who's doing what w
ps -fU < username > show process ids for username ps -fU s12345678
kill -9 <pid > kill a process by giving the process id kill -9 1046

Compiling and Running c++

Use an editor such as joe or emacs to create the program file. Say it's called fred.cc.

Compiling several classes


Say have files x.h, x.cc, y.h, y.cc, z.cc.

Abbreviations

abbreviation meaning examples
* wildcard ls *.cc     list all .cc files
. current directory cp pracs/fred.cc .       copy fred.cc to here
tab file-completion
! most recent command
| pipe to ls|more

Hope this helps ... Ros