Unix Command Summary


Basic Commands

*precede arguments with a '-' as in 'ls -al'

COMMAND PURPOSE/EXAMPLE ARGUMENTS ARG DEFINITION


ls list directory contents a include . files

l long listing

[file(s)] list a file (*=wildcard)

[dir(s)] list sub-directory contents

cd change directory (use forward slashes) [dir]

'cd /home/croger'

pwd print the working directory

'pwd'

mkdir make a new directory [dir]

'mkdir mydir'

rmdir remove a directory [dir]

'rmdir mydir'

cat display a file [file]

'cat myfile'

more display a file, 1 page at a time d include help line

'more myfile' [file] file to display

cp copy a file [sfile] source path/file

'cp sfile dfile' [dfile/dir] destination path/file

mv move a file/directory [sfile/dir] source path/file/dir

'mv sfile /tmp/dfile' [dfile/dir] destination path/dir

rm remove a file (if you have permission) r recursive down directories

'rm myfile' [file(s)] file(s) to remove

man display a manual page [command]

'man rm'

wc count character, words, lines in a file [file]

'wc -l myfile' l count lines only

w count words only

c count chars only

grep search files for a string v ignore matching lines

'grep "unix" myfile' [string] string to search for

[file] file to search


Redirection and Pipes

SYMBOL PURPOSE EXAMPLES


> redirect output of command to a file, cat myfile > myfile2

overwriting or creating the destination file cat a b c > d

>> redirect output of command to end of a file, cat myfile >> myfile2

appending-to or creating the destination file

| pipe output of command to input of command cat myfile | grep "unix"

cat myfile | grep "unix" | wc -l

ls -al | more

cat myfile | grep "unix" > resfile


email.gif (12474 bytes)

Back