0% found this document useful (0 votes)
12 views5 pages

Os 1

The document outlines tasks and exercises for an Operating Systems Laboratory course, focusing on file and directory management, command usage, and basic scripting with grep, sed, and awk. Students are instructed to perform various operations such as creating, renaming, moving files, and changing permissions, as well as working with employee and book databases. Additionally, there are exercises involving text manipulation and pattern matching using command-line tools.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views5 pages

Os 1

The document outlines tasks and exercises for an Operating Systems Laboratory course, focusing on file and directory management, command usage, and basic scripting with grep, sed, and awk. Students are instructed to perform various operations such as creating, renaming, moving files, and changing permissions, as well as working with employee and book databases. Additionally, there are exercises involving text manipulation and pattern matching using command-line tools.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Learn the following for the OS lab

Access modes, permissions


Creating files, Appending to files, deleting files, renaming files, moving files, finding files
Creating directories, deleting directories,
Virtual consoles, pipes
Operators >, >>
Commands: cd, cat, chmod, cp, date, ls, ps, pwd, sort, who

B. Tech (I. T) IV Semester


Operating Systems Laboratory

1. Identify the directory you are working in.

2. Create three sub directories in it, dir1, dir2, dir3.

3. Check if they are created and find out what permissions are given to them by default.

4. Create another sub directory sub_dir1 under dir1.

5. Create a file with name dec22_file1_2009..(roll-no) in sub_dir1 using the vi editor.

6. Find out the default permission given to the above file.

7. Display the contents of the file using “cat”

8. Add a few more lines to the file using the “redirection symbols”.

9. Edit the file by opening it in vi. Identify the keys that you use for common editing:

10. Moving the cursor up, down, left, right, replacing a character, deleting a character,
inserting a line, deleting a line.

11. Change the permission of the file that you created and find out what happens with
respect to its usage.

12. Change the permission of any directory and find out what happens to its usage.

13. What are fields that are displayed in the long listing of the directory?

14. Which are the fields that can be changed using the commands that you have seen so
far? Change them and display.

15. Create another sub directory sub_dir2 under dir2.

16. Copy the file you created in sub_dir1 to sub_dir2. Check if the task is accomplished.
What happens to the file permissions?

17. Create another sub directory sub_dir3 under dir3.


18. Move the file you created in sub_dir1 to sub_dir3. Check if the task is accomplished.
What happens to the file permissions? What happens to the file in sub_dir1?

19. Change the name of any file and see the changes that are made to its attributes in the
long listing of the directory.

20. Change to your home directory and search for a file that you have created.

21. Find out who all are currently using the server. List them in alphabetical order.

22. Can you list them according to the time in which they have logged in. (You may need
to know something extra to do this—do not bother if you cannot).

23. Find out if you can do more than one task---editing in one console / terminal, seeing
the “manual” in another and switching between them.

24. What are the processes that are currently running and how do you find them?

25. Can you identify how you can make the control characters of the keyboard work for
editing—backspace, del…
Grep Exercises.

1) Create an employee database (.txt file) which contains employee personal record. The
personal record includes name, DOB ( DD/MM/YYYY), address, phone number.
a) Print all Employee record that contain a phone number with an
Extension
b) Print all Employee record that do not begin with a capital A.
c) Print all Employee record whose name ends with Kumar.
d) Print all the Employee names
e) Print all the Mobile number and the land line number with name
f) Find the eldest and the youngest employee from the record set.
g) Find the age of all the employees.

2) Create book database (.txt file) which contains book name, author name, price,
publisher name and total page numbers.

a) Change the publisher name from Mc Graw Hill to Tata Mc Graw Hill
b) Find the list of books which are related with the keyword “database”
c) Find the price of all programming language books
d) Sort the books based on year of publication
e) delete the low price book details

3) Create a text file that contains the following strings

Aggregate, segregate, logicgate, certificate, appriviate,accumulate, accurate,acetate, adequate,


anticipate, birthdate, borate, corponate, celebrate, complicate, chocolate, illustrate, affiliate.
1) Print all the record that starts with ‘a’ and ends with ‘ate’
2) Replace ‘d’ in birthdate with ‘r’ and update in the source text file.
3) print the record that ends ‘rate’
4) Display the records with the pattern (gg) (cc) (bb) (ll) (ff)
5) Display the records that does not contains the pattern ‘gate’
4) SED exercise
a)Write a sed command that will go through a file and eliminate any .5 at the end of
a record. If .5 is anywhere else in the record, leave it alone. Have the sed command only
display those records which are modified.

Sample input :

1:3:5:7.5
1.5:2.5:3.5:7.5
1.5:2:3:4
1:2.5:3:4

b)Given a data file where each record contains four fields and each field is
separated from the others by a colon (:), write an awk command which will display the
records with fields 3 and 4 swapped.

Input:

CIS:160:374:A
CIS:170:373:A
CIS:118:374:A
CIS:111:374:A
CIS:150:375:A
CIS:123:350:A

c)Use grep to find and display all lines in a file which contain either the
string dog or the string cat.

Input: It's been quite a day.

It started when the cat woke me up.


The day was dreary. The weather
dogged me all day long.

d)This section turns a paragraph of text into something similar to leet speak.

Write a tr command that will turn all uppercase characters in a file to lowercase. Send
the output from that command to a sed script which does the following:

o convert the string ck to x


o convert the string xs to xor
o convert the string er to or
o convert the string elite to leet
o convert the character o to 0
o convert the character t to 7
o convert the character e to 3
o convert the character s to 5
o convert the character i to 1
o convert the character a to 4

Input:

The hacker elite were gathering for their


annual meeting. DEFCON had become an annual
event. The big change this year was the
appearance of more female hackers, who seemed
to prefer being known as chicks. The one
thing everyone seemed to agree on was that
Windoze security sucks.

Awk Exercise

1) Create a file with the following fields: country name, capital, area, population and
continent.

a) use awk and print the record that containing ‘asia’ and africa’

b) display the rtotal number of input record and fields for the above file.

c) set the field separator as tab (\t). display the sum of area and population for all the records.

d) select all the record that begins with letter ‘s’ through ‘z’

e) select and display all the records where the population is in 5 digit number.

You might also like