0% found this document useful (0 votes)
38 views18 pages

AOS Practical File

practical file for Advanced operating system

Uploaded by

King Saabh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
38 views18 pages

AOS Practical File

practical file for Advanced operating system

Uploaded by

King Saabh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 18
PROGR. AIM : To study about the basies of UNIX UNIX: 1 is a multi-user operating system Developed at AT&T Bell Industries, USA in 1969. Ken ‘Thomson along with Dennis Ritchie developed it from MLTICS (Multiplexed Information and ‘Computing Service) OS By 1980, UNIX had been completely rewritten using C language LINUX It is similar to UNIX, which is created by Linus Tonalds. All UNIX commands works in Linux, Linux is a open source software, The main feature of Linux is co-existing with other OS such as windows and UNIX STRUCTURE OF A LINUX SYSTEM It consists of three parts, i. UNIX kernel ii, Shells iii, Tools and Applications UNIX KERNEL: Kemel is the core of the UNIX OS. It controls all asks, schedule all Processes and carries out all the functions of OS .Decides when one programs tops and another stats L: Shel is the command interpreter in the UNIX OS. It accepts command from the user and analyses and interprets them. AIM Q 2 To study basies of UNIX commands CONTENT a iy ii) ») vii) viii) ix) FILE MANIP! Date : used to check data and time Syntax : Sdate Cal : used to display the calanler Symtax : Seal_{ month/year } Echo: used to print message on sereen Syntax : Secho “text used to list the files in the current directory Syntax : Sls ‘© Ist: Order by creation time + Is -u: Onder by access time + Iss: Order by size + Is-1: Reverse Order + Iss; Show file size Ip: used to take printouts Syntax : Sip {filename} ‘man : used to provide manual help on every UNIX commands Syntax: Sman {unix command} who & whoami = it displays data about all the users who have logged in in system currently. The next command displays data about current user only Syntax ; $who $whoami uptime: tells you how long have been system running sinee its last reboot or power off Symtax : Suptime it displays system information such as hardware platformsystem name uname processor OS type ete Syntax : Suname - AND! iii) iy) y) vi) vii) viii) ix) Cat: this create view and concatenate files Syntax : © Creation : Scat>filename * Viewing : Scat>filename © Concatenate : Scat file1>file2 Grep : used to search a word or pattern related to that word from the file. Syntax : Sgrep {search word} {filename} Rm: deletes a file from file system Syntax : $rm {filename} Touch : used to create a blank file Syntax : Stouch {new filename} Cp : copies the file from system Syntax : Sep {source file} {destination file} My: to rename file or a directory Syntax : $mv {old file} {new file} Head : displays first ten lines from selected file Syntax : Shead filename} Tail : displays last ten lines from selected file Syntax : $tail {filename} Chmod : used to change permission of a file or directory Syntax : $chmod -wx {filename} // remove write and execute permission for users PROGRAM NO 3 AIM: To study of various UNIX editors such as vi ed, ex and EMACS CONCEPT: Estria program tht allows user ose prions leon he seeen nd mol characters and lines by simply ty 4 jing atthe current position UNIX supports variety of Editors, They arv: Ed ex, vi, EMACS. Vieviis stands for sual". vi is the most important and powerful editor. is a full screen editor that allows user to view and edit entire document atthe same time.vi editor was written in the University of California, at Berkley by Bill Joy, who is one of the co-founder of Sun Microsystems. Features of vi It's easy to Team and has more powerful features It works great speed and is case sensitivevi has powerful undo functions and has 3 modes: i) Command mode ii) Insert mode iii) Escape or ex mode tn command mode, no tex is displayed on the sereen. In Insert mode, it permits user to edit inset or replace text. In escape mode, it displays commands at command line. Moving the cursor with the help ofh, 1, kj, I, ete EMACS Editor Some of motion commands are : i) M-> Move toend of file Move to beginning of file ii) Move forward a sereen Move backward in a screen vy) Cen Moxe to next line vi) C-p Move to previous line Vii) C-a_— Move to the beginning of the line viii) C-e — Move to the end of the line ix) C-f Move forward a character x) C-b_— Move backward a character xi) M-f Move forward a word xii) M-b-— Move backward a word Some of delete commands are i) DEL delete the previous character C-d_— delete the current character M-DEL delete the previous word M-d delete the next word C-x DEL deletes the previous sentence M<-k delete the rest of the current sentence C-K deletes the rest of the current line C-xu undo the lasted it change Some search and replace in EMACS i) yz Change the occurrence of the pattern ii) nzDon't changes the occurrence, but look for the other don't change. Leave query replace completely iii) | : Change this occurrence and all others in the fi PROGRAM NO 4 AIM: To write e program using following system calls of UNIX operating system fork, exe, etpid, exit, wait, close, stat, opendir, read 1. Program for system calls of UNIX OS (opendinclosedirseaddir) Finchode include include struct dient *dptr; int main(int arge, char *argv()) cl char bu[100}; DIR “Airy ("isin ENTERDIRECTORY NAME"); ‘butt prin seanfl’ if (dirp = opendie(butt)) == NULL) { print("The given directory does not exis exit) while (dptr- readdin(dirp)) ‘ print("%s\n", dptr->d_name): closedir(ditp); return 0; ) Output : 2. Program for system calls of UNIX OS ( Fork, getpid,exit) include include int main int pid, pid, pid2s pid = fork; if (pid- ‘ S CREATION\n") printf(°ERROR INPRO cexit(I); } if (pid != 9) pidl = getpid0: printf("in the parent process ID is %n" pid); else { pid2 = getpid(), print(*in the child process ID is %n", pid2); } return 0; PROGRAM NO 5 [AIM : To write simple shell programs by using conditional, branching and looping statements 1. Write a shell program to check if given number is even or odd Program : echo "Enter number" read mum if (num %2—0 yj then echo "The number Snum is eve.” else echo "The number Sum is 0 Fi Ousput Seminst 2, Write a shell program to check if given number is leap year oF not Program. echo "Enter a year: " read year if (year % 4 == 0 )); then if (year % 100 == 0 )y then i ( year % 400 == 0); then ‘echo “The year Syear isa leap year.” else ‘echo "The year Syear isnot a leap year.” fi else echo "The year Syear isa leap year fi ‘echo "The year Syear isnot a leap year.” ‘a number 43, Write a shell program to find factorial of Program, echo "Enter a number: " read number factorial=1 if ((mumber <0); then not defined for negative numbers.” echo "Factorial clit (( number = 0 )); then factorial: for (Cis; i number; i++ )); do factorial=S(( factorial * i) done fi echo "The factorial of Snumber is Sfactorial.” Output eae een e factorial of 5 is 120. \Adnin\Desktop\File> Bl PROGRAM NO ¢ ‘Aim : To write a C program for implementation of priority scheduling algorithm Program include int main) { int p{20), b(20), prif20}, we(20} ta{20}, i,k, temp; float wave, tatavE; inut"Enter the number of processes ~ for (i= 0;1< m5 +4) { pili printer he Burst Time & Priority of Process scanf{"%ed %d", &btfil, &prili)); } fori for (k= it @st> pele) t tempat vlil= ks pikl= temps temp = bi; wii} = bik simi) eijkenmkr+) prifk] = temp; } swtavg= wil0] = 0; tatavg = ta(0] = biL0}, for (i= 1; i< 1; i++) { wi} = wafi- 1) + eli Hs tat) =tafi- 1) + bulls wlayg = wlavg + wifi}; tatavg = tatavg + tat{i]; } printf("inPROCESS\\tPRIORITY\ \BURST TIMEMWAITING TIME! for (i= 0;i int main) ini, j.m, bul10}, wa 10}, tatl10},, t{10}, ma =0, att = 0, temp =o; . float a print("Enter the no of processes, seanf("%d", &n); for (i= 0:i< msi) ; printf(\nEnter Burst Time for process %d + 1; seanf("%6d", &buLil); cf] = buf; } printf("\nEnter the size of time slice ~"); scanf{"%6a", &t); max = bu{0]; for (= 1;i » include Hinelude int maind) int p{20}, be(20}, w20},tat{20}, i, k,n em float wiavg,tatavg; eo ta prinf("\nEnter the number of processes scant("%d", &biLiD); } for (= 0;i bit) { temp = bi{i]; pli] = plkl: pik) % wi{0] = wave = 0; tat{0] = tatavg = bt(0}; for i= 1;i

You might also like