Assignments Unix OS31 PDF
Assignments Unix OS31 PDF
Signature / Date
COMPANY CONFIDENTIAL
Infosys
Description Baselined
ER/CORP/CRS/OS31/002
Infosys
Contents
Contents
Assignment 1 (Day 1)......................................................................................................... 1 Assignment 2 (Day 2)......................................................................................................... 3 Assignment 3 (Day 3)......................................................................................................... 4
ER/CORP/CRS/OS31/002
II
Infosys
Assignments
Assignment 1 (Day 1)
1. Explain how the following commands would work $ cp file1 file2 file3 Try it out and verify. (Approx Time : 5mins) 2. Explain how the following command would work$ mkdir dir1 dir2 dir3 dir4 Try it out and verify. (Approx Time : 5mins) 3. How can the ls command list-hidden files? What actually constitutes a hidden file in Unix? (Approx Time : 3mins) 4. 5. Explain why the -r option of rm is dangerous. (Approx Time : 5mins) Draw the tree structure of the file system created by the following commands (assume you are in the directory /usr/office) (Approx Time : 10mins) $ mkdir left $ mkdir middle $ mkdir right $ cd left $ mkdir left middle right $ cd ../middle $ mkdir dir dir1 /usr/office/right/dir3 6. With reference to the last example why is it not possible to issue the command rmdir /usr/office/right? (Approx Time : 3mins) 7. Explain three circumstances when a directory file cannot be removed using the rmdir command (not including any factors involving file permission settings ) (Approx Time : 8mins) 8. Use mv to rename a set of files m* to t*. Does it work? Explain the results (Approx Time : 5mins). 9. Create a link to a file. Check the link count and i-node number of both the files. Why is it that both the files have the same i-node number? Use rm to remove one of the files. What happens to the link count? (Approx Time : 10mins) 10. List the names of all processes not associated with any terminal. (Approx Time : 8mins) 11. How do you delete five lines above the current line, including the current line? (Approx Time : 5mins) 12. If you delete a line, and paste using p, where would it get pasted? (Approx Time : 5mins) 13. How will you replace the string friend with foe? What is the equivalent instruction in the ex mode. (Approx Time : 5mins) 14. How would you delete 3 lines at once, paste it twice. (Approx Time : 2mins) 15. What are o and O used in Unix. (Approx Time : 2mins)
ER/CORP/CRS/OS31/002
Infosys
16. What is the use of J ? (Approx Time : 1min) 17. How do you insert some text at the a) Starting of the current line. b) Ending of the current line. (Approx Time : 2mins)
Assignments
18. What is ZZ used for? (Approx Time : 2mins) 19. How do you undo and redo in vi Editor? (Approx Time : 2mins)
ER/CORP/CRS/OS31/002
Infosys
Assignments
Assignment 2 (Day 2)
1. Explain the command $ cat meat 1> Pluto (Approx Time : 5mins) 2. 3. 4. List all the users who have logged in more than once. (Approx Time : 4mins) What action does the touch command perform? (Approx Time : 3mins) A typical who command displays data in the following format root tty1 Jan8 11:55 mary tty12 Jan8 14:16 How can you sort the fourth column of data in this listing using the sort command ? (Approx Time : 5mins) 5. Write a grep command to find the users who are not using terminal tty2, tty3 or tty4. (Approx Time : 8mins) 6. What is the difference between the two commands below? (Approx Time : 5mins) (a) who | tail +1 (b) who 7. Use the command touch <filename> on an existing file. Use ls and observe what happens. Try the same thing on a non-existent file and observe the results. (Approx Time : 5mins) 8. 9. Use kill to terminate your Shell. Try to explain the results. (Approx Time : 5mins). List the lines 5 - 10 of a file. (Approx Time : 5mins)
10. Count the number of files owned by you. (Approx Time : 5mins) 11. List all the filenames and their sizes in ascending order of size. (Approx Time : 6mins) 12. List all the possible users working on more than one terminal. (Approx Time : 5mins) 13. Find all instances of fprintf( ) in all the C program source code, residing in your current directory. (Approx Time : 5mins) 14. Suppose inadvertently a regular expression itself was allowed into a file. How do you locate the line containing it ? (Approx Time : 7mins) 15. How do you locate the lines containing Saxena and Saksena from a file ? (Approx Time : 6mins) 16. Locate all lines beginning with a dot (.) in the file (Approx Time : 3mins). 17. How would you delete lines containing white space from a file ? (Approx Time : 4mins)
ER/CORP/CRS/OS31/002
Infosys
Assignments
Assignment 3 (Day 3)
1. Write a Shell script that requests your age and then echoes it along with a suitable comment. (Approx Time : 5mins) 2. Write a Shell script to reverse a string. The string is to be passed as a command line argument. (Approx Time : 10mins) 3. Point out the error in the following Shell Script (Approx Time : 4mins) echo What day is today ? read $day1 echo day1 is a good day as any 4. 5. 6. 7. 8. 9. Write a shell script which takes an argument & finds if prime or not. (Approx Time : 15mins) Write a shell script to find if the number is even or odd. (Approx Time : 15mins) Write a shell script to see if a particular user has logged in. (Approx Time : 15mins) Write a shell script to convert a decimal number to binary. (Approx Time : 15mins) Write a shell script to find a factorial of a number. (Approx Time : 15mins) Write a shell script which finds the length of a string. (Approx Time : 15mins)
10. Write a shell script which gives a count of the directories & the files in any directory. (Approx Time : 15mins)
ER/CORP/CRS/OS31/002