Posted by: tonyteaching | August 3, 2008

UNIX Basic Commands

Link to Unix Command dictionary:


More UNIX tutorial:


“The Shell” : is the Unix Interpreter

There are many kinds Unix systems –> there are many kinds of Shells

in Infoeng labs: “tcsh” (‘tee-see-shell’)

UNIX Command Form:

command options parameters


we can use command without or more than one options and parameters

we can also use more than one commands by using PIPE syntax

Typically, the command: Acronym of full description of the command



add_ict1 ………………..for Tutor to add check point (this command will be responded by question ‘what checkpoint numbers want to check’ and user+password the Tutor (Tutor needs to ask Topic Coordinator that He has setup access for him, and ask about the username and the password?)

or if the tutor wants to add more than one check points (max 31)

checkpoints -D comp1301

show_ict1 …………………to show how many checkpoints the student (who login using the workstation) has.

To Change Password


0. man or whatis or man -f (View the MANUAL)


man ls “view manual of ls command (completely)”

man -f “view just brief summary of the manual (1 line)”

man -f ls

whatis “summary the manual”

man -f

whatis ls

man -k “view summary manual related to a keyword”

man -k ls

1. ls (List the directory contents)


ls “list the Directory contents”

(the Unix directories will be hiden – started with ‘.’)

ls -al “list the Directory contents”

(included Unix directories)

ls -l “list the directory contens with Long (-l) format (each file’s permissions, modification date,size, owner)

ls -l aku.txt “list detail of the file ‘aku.txt’ (parameter) with Long format”

ls -l aku “list the contents of the Directory ‘aku’ (parameter) with Long format”

ls -R “list the content of a tree directories (Root Structure)”

2. talk (chatting)


talk susa0004 “call username (susa0004) in the same server”

talk “call susa0004 on different server (”

^c (control c) “break the connection”

to establish the connection, susa0004 should reply with typing the same

talk marl0024 (if your username ‘marl0024’)

if you want to know what is your Server’s Name: hostname


if you want to know who are log in the current Server : who

calender : cal

3.history (view the list of previous commands that we have typed)


history “view the list of previous commands”

!! “repeat the previous command”

or with ARROW keys

!23 “repeat the command number 23”



To Create/write the file can use NotePad or CDE Editor

more Tony.txt “display the contents (more) of file Tony.txt”

(‘more’ command is just .txt file)

cp Tony.txt otherTony.txt

“copy (cp) file ‘Tony.txt’ in the same directory with name ‘otherTony.txt'”

5. PRIVILEGES of a file


when we show all information about a file with “ls -l thefilename”

There are 3 privileges:

read (r)

write (w)

executable (x)

There are 3 seperate groups of file users


The user themselves(u) The specified group of users(g) Any other user(o)

chmod “change mode of the priviledge”

chmod g+rw Tony.txt

“change mode: Add for Group READ WRITE priviledges for file Tony.txt”

the file’s privileges will be


chmod o-rwx Tony.txt

“change mode: Erase for Other user READ WRITE EXECUTABLE priviledges for file Tony.txt”

the file will be


6. Files and Directories



“print work directory – to show what the current working directory is?”



cd ~ “back to home directory”

cd ~/ict1 “back to home directory and move to ict1 directory”

cd /opt/teaching “move to directory ‘opt’ and further move to subdirectory ‘teaching'”

cd . “move to current directory”

cd .. “move to Parent directory/ 1 step closer to the root”



mkdir unix “make directory ‘unix’ in current directory”



cp /opt/teaching/pracs/prac11/office.txt .

“copy file ‘office.txt’in specific directory to active/current directory with the same name”

cp /opt/teaching/pracs/prac11/office.txt ..

“copy file ‘office.txt’ to parent directory of active directory with the same name”

cp /opt/teaching/pracs/prac11/office.txt ~/data/office_baru.txt

“copy office.txt to directory ‘data’ with new name ‘office_baru.txt'”




“rename ‘’ to be ‘’ in same directory”

mv ../

“rename ‘’ to parent directory with new name ‘’

mv rubbish

move ‘’ to ‘rubbish’ directory

so when using mv command, if the targeted file followed by

another file‘s name –> Rename

directory name –> Move

DELETE/REMOVE (rm) (rmdir)


rm rubbish/

“remove/delete file ‘’ in directory ‘rubbish'”

rmdir rubbish

“remove/delete directory ‘rubbish'”

7. PRINT (lp)


lp [-d printername] [options…] filename

-os : single sided

-od : double sided

-o4d : 2 pages per side


lp -d max -os

“print’’ file to ‘max’ printer with simplex output”

lpstat -R “check the status the print job”

8. Wild character


? one any character

* zero or more characters

mv T* ~/data

“move all file in current directory started ‘T’ to directory ‘data'”

mv a8 a9 10 ~/data

“move three data a8,a9,a10 to ‘data’ directory”

ls ??

ls a*c.*

ls a* *c

ls a? ?c

ls b? ?b b?? ?b? ??b list all files that contain a ‘b’

ls *b*b*



sort Tony “sort the lines of ‘Tony’ file into alphabetical order”

sort < Tony > Tony_sorted “sort input from ‘Tony’, output to ‘Tony_sorted'” (automaticaly Unic create the new file ‘Tony_sorted'”

“PIPES” : combination of Filter Commands


sort < Tony | nl ” sort file ‘Tony’ then numbering the lines”

sort -r “sort reverse”

grep c < /usr/dict/words | wc ” search the line which contains ‘c’ character from file ‘words’ then count the number of characters, words, and lines”

wc < /opt/teaching/comp1101/pracs | sort | head -1 “Word Count the files in directory ‘pracs’, Sort the files based on word count, then display the first line (the fewest lines)”



sort (then press ‘return’)

(type) alpha (then press ‘return’)

(type) bravo (then press ‘return’)

(type) charlie (then press ‘return’)

(type) delta (then press ‘return’)

(type) echo (then press ‘return’)



cat file1 [file2 …] “display the contents of file1” (CAT only is available for text files: mail message, source code, web page,…)

more file1 [file2 …] “display *.txt file”

Note: This file can be download here unixbasiccommands

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: