You are on page 1of 10

UNIX SYSTEM ORGANISATION The functioning of unix is manned in three levels.

On the outer crust reside the application programs and other utilities, which speak our language. At the heart of unix is the kernel which interacts with the h/w in the m/c language. The streamlining of these two modes of communication is done by the middle layer called the SHELL. There are three layers of unix OS. The shell or the command interpreter as it is called is the mediater which interprets the commands that is given to it and conveys them to the kernel which executes them finally. The kernel has various functions like managing files, carrying out data transfer between file system and the h/w aond also manages memory. The kernel program is usually stored in a file called 'UNIX' and the shell program is stored in a file called 'SH'. TYPE OF SHELLS :1. BOURNE SHELL :This shell is most widely used shell by many unix users. It was bundled with every system that came then. 2. C SHELL :This shell is a hit with those who are seriously in to unix programming. It has two advantages over the bourne shell. Firstly C shell allows aliasing of commands i.e, instead of typing a lengthy command, we can rename that command by a short alias name. Secondly, C shell has command history feature. Previously typed commands can be recalled, since the C shell keeps track of all commands issued at the command line. This feature is similar to the one provided by the program DOSKEY in MS-DOS environment. 3. KORN SHELL :They are not so widely used. But this shell is very powerful and is the superset of the bourne shell. It offers a lot more capabilities and is more efficient than the other. UNIX FILE SYSTEM Unix treats everything it knows and understands, as a file. Even a directory is treated as a file which contains several other files. The unix file system resembles an upside down tree which begins with a directory called ROOT, which is denoted as '/'. Branching from the root there are several other directories called BIN, LIB, USR, ETC, TMP and DEV which are the subdirectories. The root directory also contains a file called UNIX which is Unix Kernel itself. Each of the sub-directories contain several files and directories called sub-sub-directories. BIN -- Executable files for most of the unix commands LIB -- All library functions provided for programmers USR -- All user related files. Here there are several directories each associated with a particular user. DEV -- Files that control various i/o devices like terminals, printer, disk drives etc. TMP -- Temporary files created by unix or by the users for a temporary purpose. ETC -- Binary executable files usually required for system administration. Features of unix file system :1. It has a hierarchial file structure. 2. Files can grow dynamically. 3. Files have access permissions.

4. All devices are implemented as files. UNIX COMMANDS AND THEIR FUNCTIONS WITH EXAMPLES ===================================================== COMMAND PLES ---------UNIX Touch uch sample DOS(EQ) Used to create empty files $ to -Thi s creates a file sample with 0 bytes. Cat t test type Used to display the contents of a file or to $ ca -Dis $ ca t > test (ctrl-d to terminate) -Dat a can be entered into the file test. $ ca t s1 s2 >> s3 -s3 contains its old contents along with the contents of s1 and s2 appended. Cp f1 f2 copy Used to copy the contents of one file to another $ cp -Con tents of f1 are copied to a new file f2. Rm -i f1 del Used to remove a file in various ways $ rm -Fi us $ r -Dir ectory dir1's contents are deleted rec ursively. Mv f1 f2 move Moves(renames) one file to another. Directory's name can also be renamed. e f1 is renamed as f2. Ls /D1 dir Displays the contents of a directory in various $ ls -Con $ mv -Fil ----------FUNCTION EXAM

enter data into a file plays the contents of test.

-i removes file after conformation(interactively) le f1 is deleted after conformation by -r removes the contents of the directory er. -f removes file forcibly m -r dir1

ways. tents of directory D1 are displayed

-a s ?ain

along with hidden files(.)

$ l -Dis wi $ l -Di wi $ l -Di wi $ ls

- ordinary file plays the names of all files ending d directory file th 'ain'. c character special file s p* b block special file splays the names of all files starting l symbolic link th the letter 'p'. s semaphore s [aieou]* p named pipe splays the names of all files starting m shared memory file th vowels. -l

-Ind icates it is a long list and displays alo ng with the file type. -rw xr-x--x 1 user 1 group 17jun06 1:10 f1 drw xr-xr-x 1 user 1 group 10jul07 2:15 f2 Ln f1 f2 Establishes one more link to a file in order to $ ln -Est the form of the name 'f2'. Lc dir Used in same manner as ls $ lc -Dis plays contents of current directory. Lf 1* sub-directories. 2 d 1/ Pwd d 'Present Working Directory'. usr/user1 Mkdir md Used to create a directory. -p Used to create multiple generations of $ mk -Dir b w / Used to find which directory a user is in. $ pw f Same as ls,but differs by showing a '*' before executable files and a '/' after all $ lf f

help during accidental deletion. ablishes one more link for file 'f1' in

dir -p w/b/v/b directories. ectory w is created with sub-dir

hich contains v which finally has ano ther sub-directory. Rmdir rd dir -p w/b/u To remove a directory. $ rm -If emp ty b is also removed. Cd cd kdir newdir d newdir Bc /2 * 2 -l used to invoke sine & cosine functions. 5 * 2.5 + 2 8. 25 qu it Expr pr 100 + 50 0 point arithmetic. pr 3 \* 2 6 Factor ctor 3 5 45 9 5 q $ Units its u have : inch equivalents in other scales. u want : cm * 2.540000e+00 / 3.937008e-01 To yo Used to convert quantities expressed in various standard scales to thier $ un yo Factors of an input number is printed out. $ fa 15 $ ex Used to evaluate expressions. drawback:- can't handle floating $ ex 15 10 2. Used to calculate an expression and give an output $ bc 10 Used to change directories. $ m $ c

-p Removes parent directories of a directory. on removing u, then if directory b is

convert inches to cm multiply the no by 2.54 or divide it by e-01. Logname Prints login name of user gname er1 Id d= 202 (user1) gi d= 50 (group) Uname ame osysv tty y ev/tty1a who o to find name of unix system $ un sc to find name of your terminal file. $ tt /d lists all the users of the system. $ wh us er1 tty1a apr10 01:20 us er2 tty2a apr10 01:20 us er3 tty3a apr10 01:20 date date to display current date and time te t apr 20 01:20:10 ist 1998 $ da te '+DATE:%d -%m -%y %n TIME:%H:%M:%S' DA TE : 17-06-1996 TI ME : 10:55:25 passwd sswd to set and change a password. $ pa ol d password is asked for conformation an d then new password is entered twice an d this is not visible on screen. cal used to print the current month dates or l 2 1998 for a year. braury 1998 m tu w th f sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 $ ca fe s $ da sa used to identify user by user & group id. $ id ui $ lo us

17 18 19 20 21 22 23 24 25 26 27 28 banner mode to print a message in large letters. anner HI -co40 [large] -co80 [normal] # # # # ### ##### # # # # file file * # # # dir/v to display files along with a message $ $ b

# #

verbose of what it contains. a.out : ipax 386 executable mode ban : empty bi n : directory dosdir dir a: dosdir a: to read a dos formated floppy. $ di splays all files in a: doscat type a:f to display contents of a dos file in a: doscat a:a.out f-file displays a.out file's contents |||'ly for dosmkdir, dosrm, dosls, dosformat, doscp. wc f1 f2 20 571 f2 30 804 | | li nes characters sort rt m1 m2 m3 used to sort contents of a file and also $ so so in used to count no of lines,words and characters in files. $ wc f1 $

to merge multiple sorted files and store rts files m1 m2 and stores the result the result in a specified file. a newfile called m3.

-b ignores leading spces and tabs -c checks if files are already sorted .if they are , sort does nothing. -d sorts in dictionary order. -f ignores case. -m merges files that have already been sorted. -n sorts in numeric order -o file stores o/p in file.the default is to send o/p to std o/p. -r reverses sort -tc seperates fields with character -u unique o/p.if merge creates identical lines ; uses only the first +n[-m] skips 'n' fileds before sorting and then sorts through filed 'm'. cut ut -f 2,7 f1 cuts or picks up a given no of character $ c -

or fields from specifed file. 2nd and 7th fileds are cut and displayed.

$ c ut -f 2-7 f1 fileds 2 through 7 are displayed. grep rep picture f1 globally search a regular expressin and $ g -

print it.it searches the specified input searches the word 'picture' in file f1 fully for a match with the supplied pattern and if found displays the lines that and displays it. matches the word. -c returns only the number of matches without quoting the text. -i ignores case while searching. -l returns line no of matched text as well as the text itself -s suppresses error messages. -v returns lines that do not match the text. '^[abc]'-search those lines which begin with 'a' or 'b' or 'c'. '[s-z]$'-search those lines which end with any character between 's' to 'z'. dd used for file manipulations.converts and copies a file d if=rep of=doc conv=ebcdic ucase with plenty of choices. onverts i/p file rep from ascii to option meaning bcdic and convert map alphabetic in count=n copy only n input records. pper case & copy them to the o/p file conv=ascii convert ebcdic to ascii alled document. conv=lcase converts alphabets to lower case conv=noerror continue processing if error occurs. conv=...,... several comma seperated conversions.

$ d c e u c

skip=n head ead -15 f1

skip n input records before starting to copy. $ h -

used to view the lines at the beggining of the file.

displays first 15 lines of a file. tail used to view the lines at the end of the file ail -15 f1 isplays the last 15 lines of file f1 pg displays contents of file pagewise g +10 -15 -p "page no .%d " -s f1 isplays contents of file f1 15 lines

$ t -d $ p d a

t a time from 10th line onwards.at the e nd a prompt displays the pgno. s reverse video. more same as pg. ps ps PID mem to find what are the processes that are /c are running at any instant. TTY TIME COMMAND /d 2269 3a 0:05 sh 2 396 3a 0:00 ps background to do some process in the background and sort e.dat > e.out & process continue with some other work. 17653 re file e.dat gets sorted and is sto red in a file e.out and this takes pla ce in the background and you are free to do some other operation. nohup to ensure that the terminal does not get ohup sort e.dat > e.out terminated. 7965 ow we can safely log out wi thout any hangups & without our pr ocess getting terminated & when we lo g in the next time our o/p file wi ll be there. kill used to terminate a process if $ c $ n 1 -n $ $

$ -he

at a.emp | sort > o.out & an indefinte loop is getting executed. 24 a terminal has hung up. ill 124 due large no of programs getting executed 24 terminated in the background. even if file does not get terminated use -9 to terminate it. Nice To change the priority of a process(even a ice -10 cat e.dat background process) initially e.dat had a priority 20,now priority range 0 to 39. Default is 20. would be decreased to 10. Super user level $-User level At t 17:00 To execute commands at a future date & time

1 $ k 1 -

# n -If it #$ a c

lear > /dev/tty3c e cho "Hai" > /dev/tty3c c trl d j ob 803103421.a at fri jun 14 1 7:00:00 IST 1996 $ a t 17:00 -Th is command would give the particular te rminal the specified message at the sp ecified time. Batch $ batch *.bat To do some commands batchwise at a time when the

file system's load is light. sort e.dat | grep Nagpur > a.nt J ob 6932200.bat fri jun14 17:00:00 I ST 1996 b -Used to indicate it is a batch file. Write $ write user2 To write a message on some terminal. H ey there! How are you c trl d T

he message would be displayed on the t erminal of the user whose name is user2 Mesg $ mesg -y $ mesg -n Finger $ finger -i Login ser1 ser2 TTY Can be used to switch on/off the messages coming to a -to accept messages terminal. -to block messages To check which terminals allow messages to come and which do not. when idle u *tty01 fri oct13 17:00 40 secs u tty3f fri oct13 10:00 Mail $ mail user2 To send messages to terminals. sub ject : You have a Unix test on sunday ctr l d The message would be displayed on user2's ter minal.

You might also like