You are on page 1of 11

1

.a) Using LINUX commands, i. Copy a directory ( with all files ) to a new directory Cp-r /directorytocopy/newdir/ ii. iii. iv. Remove files that start with cha. rm [c][h][a]* Remove all files in a directory at once. rm ./* Order Files Based on Last Modified Time (In Reverse Order) Ls -ltr

c)

b). Simulate the execution of ls command in the child process. Write a C program to schedule the incoming job so that the shorter working time process will complete its execution earlier. 2. a) Using LINUX commands, i. To count the number of files in the current directory. Ls |wc-l ii. To find the record length of first record in a stud file. ( Create stud file initially ). head -1 stud|wc c iii. iv. Edit the last modified file. ( Use Vi editor for editing ). Display the hidden files, but not the . (current directory) and .. (parent directory). Ls -A b) Write a C program to simulate LINUX command processor. c) Write a C program to simulate grep command. 3. a) Using LINUX commands, i. Change the first three records in a emp file from lower case to upper case. ( Create emp file initially). Head -3 emp|tr a-z A-Z ii. Store the sorted list of users to a file called users.

Who |sort>user iii. Create nested directories using one mkdir command. If any of these directories exist already, it will not display any error. If any of these directories doesnt exist, it will create them.

Mkdir vino pappu thanga divya b) ) Write a C program to simulate RR scheduling. c) Write a C program to simulate wc command. 4. a) Using LINUX commands, Display all files whose names start with alphabets from m to t. Ls [m-t]* ii. iii. iv. Display all files whose names do not begin with lowercase letters. Display the user list in FIFO order. Who|sort Display the number of files containing the word the in your current working directory. grep the [a-z]* | wc l b) ) Write a C program to simulate ls -l command. c) Write a C program to simulate SJF scheduling 5. a) Using LINUX commands, i. List only the directories in the current directory. Ls |grep^d ii. Display the number of lines in any text file that contains at least a single lowercase letter a. Grepa*.[t][x][t]|wc l iii. Display no. of users currently logged in. Who|wc l iv. Sort the contents of a directory, then redirect the output to a file. Ls|sort>file1 b) ) Write a C program to simulate cat command. c) Write a C program to simulate priority scheduling.

i.

6. a) i) Create a directory called user under the root directory. Copy file called red, white, blue and pink from a directory called color. Rename the file called white to a file called green.

Mkdir user. Mkdir color Cd color Touch red Touch white Touch blue Cp r color user. Mv white green. ii) Suppose we have three files called first name, second name and last name. List all the files to display the output as first second last names. Paste firstname secondname thirdname b) Write a C program to implement IPC using message queues. 7. a) Make a directory called user. Copy two files called abc and xyz to the directory. Copy three more files called lmn, pqr and def to user directory. List the contents of the directory and delete the directory and its files. Mkdir user. Touch abc;touch xyz;touch lmn;touch pqr;touch def Rm r user b) Write a C program to simulate FIFO scheduling. c) Write a C program to display the numbers from 1 to 10 using both parent and child processes. 8 a) Create a file called places with sample data as: Bombay Karachi Nairobi i. ii. iii. India Pakistan Kenya 45677 58476 32916 asia Asia africa

List the details for the countries usa, Kenya and Canada. List the details of the continent asia. Display the list of those countries whose population is between 40000 and 60000. iv. Extract the lines which end with ia. b) Write a C program to simulate SJF and priority scheduling. 9. a) i) Create a file called top. Display the first three and last three lines of the file.

ii) List the contents of a file from the fourth line from the end of the file and list the contents of a file from the seventh line from the beginning of that file. Tail -4 top Split -7 top|cat xab

b) ) Write a C program to simulate ls command using IO system calls. c) Write a program to produce n number of items and consume those items simultaneously but overproduction and under consumption should be avoided. Use semaphore concept to implement this 10. a) Create a file called list as : S0001 S0005 i. ii. iii. iv. raja semp 78 Usha semr 96

Display the contents of the file sorted according to marks in the descending order. Display the names of the students in the reverse order ignoring case. Display the list of students who have secured marks between 50 and 80. Sort the file according to third field and dump it to a file called ccode. b) Write a program to schedule the incoming job in the same order of arrival. c) Write a C program to perform file allocation.

11.a) i)Display the contents of a file converting all lower case letters to upper case letters Cat ff|tr a-z A-Z ii) Display only the first field of first ten lines of any sorted text file containing students information. b) Write a C program to simulate cp command using IO system calls. c) Write a C program to implement FIFO page replacement. 12. a) Create a directory called map. Copy a file from the current directory and rename it as new name. Crate a directory called target. Move the same file to directory target. Display the contents of that file. Remove the file. List the contents the directory. Change to home directory. Mkdir map Cat>>sasi Mv sasi newname Mv sasi target Rm sasi Ls Cd ~ b) Write a C program to implement producer/consumer algorithm. c) Write a C program to implement cat command using IO system calls. 13.a) Create a file emp as : E0001:malan:mktg:5000 E0010:balan:acct:7000 i. Sort the file on the employee and display the name of the employee and department.

List the employees who earn between 4000 and 6000. Sort the file on the employee name in reverse order and extract the codes and their names. iv. List the duplicated records of the file and dump it to a file called dup. b) Write a C program for synchronization problem of producers and consumers as described below: Producer process: do 5 times: produce, sleep for 1 second enddo Consumer process: do 5 times: consume, sleep for 1 second enddo Any number of producer and consumer processes can be started. c) Write a C program to implement first fit algorithm. 14. a) Using LINUX commands. i) Display the no of logged in users having their usernames start with exam. ii) To count the no. of files in the current directory that contain the word cse. Grep cse[a-z]*|wc l iii) To count the no. of files that end with .c wc -l*.[c] iv) Delete a directory and all the files and subdirectories in it. Rm r directoryname b) Write a C program to simulate rm command. c) Write a C program to implement best fit algorithm 15. a) Using LINUX commands, i. Copy a directory ( with all files ) to a new directory ii. Remove files that start with cha. iii. Remove all files in a directory at once. iv. Change file permissions read only for any text file. Chmod 444 a.txt b) Simulate the execution of who command in the child process. c) Write a C program to implement worst fit algorithm

ii. iii.

16. a) Using LINUX commands, i. To count the number of files in the current directory. Ls |grep v^d ii. To find the record length of first record in a stud file. (Create stud file initially ).

iii. iv.

Edit the last modified file. ( Use Vi editor for editing ). Change file permissions to executable for any file. Chmod 777 [a-z]*

b) Write a C program to simulate a LINUX command processor. c) Write a C program to implement contiguous file allocation. 17. a) Using LINUX commands, i. Change the first three records in a emp file from lower case to upper case. ( Create emp file initially). ii. Store the sorted list of users to a file called users. iii. Recursively list all the files in the current directory and any subdirectories of the current directory. Ls R iv. find all files created on a particular date ie. today. Find maxdepth | -type d mtime -1 b) Write a C program to implement to implement producer / consumer problem. Producer should produce first n odd numbers and consumer should consume them. c) Write a C program to implement FIFO page replacement. 18. a) Using LINUX commands, i. Display all files whose names start with alphabets from m to t. ii. Display all files whose names do not begin with lowercase letters. iii. Display the user list in FIFO order. iv. Display the number of files containing the word the in your current working directory. b) Write a C program to create 5 processes where the first process is the parent of the second and third ones and the third process is the parent of the fourth and fifth ones. Your program should be capable of; i. ii. iii. checking if the processes are forked with success, printing the pid and parent pid of each process, printing the parent pid of the first process.

Fork Example with 5 processes

i.

19. a) Using LINUX commands, List only the directories in the current directory. Ls

ii. iii. iv.

Display the number of lines in any text file that contains atleast a single lowercase letter a. Display no. of users currently logged in. Display matched lines containing hello or Hello in any text
file.

Grep[h-H]ello x.txt b) Write a C program to implement wc command. c) Write a C program to simulate scheduling based on time slice.(rr) 20. a) Using LINUX commands, i. Change the first three records in a emp file from lower case to upper case (Create emp file initially). ii. Store the sorted list of users to a file called users. iii. Display the contents of any directory in upper case Ls|tr a-z A-z iv. Display the list of C files only. Ls *.c b) Write a C program to implement cp command. c) Write a C program to implement any classical synchronization problem. 21. Using LINUX commands, i. Display all files whose names start with alphabets from m to t. ii. Display all files whose names do not begin with lowercase letters. iii. Display the user list in LIFO order. iv. Display the number of files containing the word the in your current working directory. b) Write a C program to implement producer consumer problem using semaphores. c) Write a C programe to implement date command. 22. a) Using LINUX commands, i. Display all files whose names start with alphabets from m to t. ii. Display all files whose names do not begin with lowercase letters. iii. Display the user list in LIFO order. Sort r|who iv. Display the number of files containing the word the in your current working directory.

b) Write a C program to implement producer consumer problem using semaphores. c) Write a C program to implement worst fit. 23 a) Using LINUX commands, i. Store the first 200 lines of the manual page of cat command in a file called catman. Man cat |head -200>cat man ii. To count the no. of lines, words and characters in any text file. Wc sr.txt iii. iv. To display the first three fields of the current date. To simulate ls command using pipes and filters. b)Write a C program to simulate FIFO and RR scheduling

24.

a) Create a file called places with sample data as: Bombay Karachi Nairobi India Pakistan Kenya 45677 58476 32916 asia Asia africa

List the details for the countries usa, Kenya and Canada. List the details of the continent asia. Display the list of those countries whose population is between 40000 and 60000. iv. Extract the lines which end with ia. b) Write a C program to implement wc command. c) Write a C program to simulate scheduling in a super market that serves the customer with less purchase.(sjf) 25. a) Create a file called top. Display the first three and last three lines of the file. b) List the contents of a file from the fourth line from the end of the file and list the contents of a file from the seventh line from the beginning of that file. c) Write a C program to simulate producer that produces the square of any 10 numbers and consumer to consume them. d) Write a C program to simulate date and time command. 26. a) Create a file called list as : S0001 raja semp 78

i. ii. iii.

v. i. ii. iii. iv.

S0005 Usha semr 96 Display the contents of the file sorted according to marks in the descending order. Display the names of the students in the reverse order ignoring case. Display the list of students who have secured marks between 50 and 80. Display the list of students and their registration numbers. Sort the file according to third field and dump it to a file called ccode. b) Write a C program to display the contents of a file.(cat) c) Write a C program to implement FIFO page replacement.

i.

27. a) Using LINUX commands, List the long listing of all the files in /usr directory that start with i and have a second character i, c or any letters from s through y. Ls l [i][I,c,s-y]

ii. iii. iv.

To display the records of employees whose salary is between 7000 and 7999 Extract logins of people whose login names start with ex. Display the date in the mm/dd/yy format, along with the present time in AM/PM. Date +%D,+%r b) Write a C program to implement first fit and best fit algorithm. 28. a) Using LINUX, Display all files whose names start with alphabets from m to t. Display all files whose names do not begin with lowercase letters. Display the user list in FIFO order. Display the user list in FIFO order. b)Write a C program to list all files of a particular directory. c) Write a C program for best fit. 29 a) Create the given directory structure.
NEC CSE IT MECH EEE SEC A ECE EIE SEC B

SEC A SEC B Mkdir nec Cd nec Mkdir CSE IT MECH EEE ECE EIE Cd CSE mkdir secA secB Cd .. Cd ECE Mkdir secA secB Cd MECH Touch test1 test2 Cd nec

b) Create two files test1 and test2 in the directory MECH. Ls R

c) Display the contents of the directory NEC with its subdirectories and files. d) Copy the two files to directory SEC A in CSE directory and to SEC B in ECE directory. e) Write a C program to stimulate best fit and worst fit algorithm. 30. a) Using LINUX, List only the directories in the current directory. Display the number of lines in any text file that contains atleast a single lowercase letter a. Display no. of users currently logged in. b) Write a C program to simulate sort command. c) Write a C program to simulate Linux command processor. 31. a) Using LINUX commands, i. Display the first four lines of any file. Head -4 filename ii. iii. Replace the word will with would in that file. Display the last line of that file. Tail -1 filename b Write a C program to simulate placement policies.(fit ) 32. a) Using Linux, i) List the long listing of all the files in the /usr directory that start with a and have a second character a, c or any letters from s through y. ii) To count the number of differences between any two files. diff emp1 emp2|wc iii) To count the no. of files in the current directory that contains the word cse. iv) To count the no. of logged in IT users. b) Write a C program to implement RR and Priority Scheduling. 33. a) Using Linux, i) Display lines 5 to 10 from a file. Split -5 filename|cat xab ii) Sort emp file on the month of birth (create emp file initially). iii) Display the current date in the format dd/mm/yyyy.

Date +%D iv) To remove duplicates from a file. Sort m.txt | uniq b) Write a C program to simulate echo command. c) Write a C program to print characters from A to Z in the child and numbers from 1 to 20 in the parent processes respectively.

34. a) Using Linux, i) Delete all new line characters in a text file. Cat sn.txt|tr \n \t ii) List all the files that do not begin with alphabets. iii) Display the total size of all .c files wc c *.[c] iv) Remove all files with three character extensions except .cpp files. Rm !(*.cpp) b) Write a C program to simulate First fit and best fit algorithm. 35. a) Using Linux, i) List the contents of the current directory in 4 columns. ii) To list only the files in the current directory. Ls|grep v ^d iii) List all the files beginning with an alphabet inspite of its case. Ls -a iv) List all the files with a single character extension but not .C and .O files. Ls *.[c],*.[o] b) Write a C program to simulate cp command, c) Write a C program to simulate date command in the child process and wc command in parent process.

You might also like