OS Lab 6
OS Lab 6
Operating System
Lab # 06
Presented By:
Ahmed Mehmood RCF-30145
Presented To:
Ms. Tehreem Tajammal
Lab Tasks
Task-1
I. Type in the example on the cut slide to display a list of users logged in. (Try just
who on its own first to see what is happening.)
II. Arrange for the list of usernames in who’s output to be sorted, and remove any
duplicates.
III. Try the command last to display a record of login sessions, and then try
reversing
it with tac. Which is more useful? What if you pipe the output into less?
IV. Use sed to correct the misspelling ‘environment’ to ‘environment’. Use it on a
test
file, containing a few lines of text, to check it. Does it work if the misspelling
occurs more than once on the same line?
V. Use nl to number the lines in the output of the previous question.
Task-2
I. Try making an empty file and using tail -f to monitor it. Then add lines to it
from
a different terminal, using a command like this:
a. $ echo "testing" >>filename
II. Once you have written some lines into your file, use tr to display it with all
occurrences of the letters A–F changed to the numbers 0–5.
III. Try looking at the binary for the ls command (/bin/ls) with less. You can use
the -
f option to force it to display the file, even though it isn’t text.
IV. Try viewing the same binary with od. Try it in its default mode, as well as with
the options shown on the slide for outputting in hexadecimal
Task-3
I. Use the split command to split the binary of the ls command into 1Kb chunks.
You might want to create a directory especially for the split files, so that it can all
be easily deleted later.
II. Put your split ls command back together again, and run it to make sure it still
works. You will have to make sure you are running the new copy of it, for
example ./my_ls, and make sure that the program is marked as ‘executable’ to run
it, with the following command: $ chmod a+rx my_ls