Homework 3
Purpose: Practice file and process related commands in a Linux shell.
Look through the manual pages of the commands you use and try to understand some of the options.
Try to use as many shortcuts you discovered in Homework 1&2 as possible
(copy&paste, Up Arrow, TAB, etc). Typing is a waste of time.
1. Open several terminal windows and a web browser displaying this page.
2. Try to remove the test directory that you created in Homework 2 with
one command, even if it is not empty (Hint: read again the manual page
of rm).
3. Create a directory named test1. Save the surce of this web page as a
html file named h.html (Hint: use the File menu of the web browser).
4. Add the following text "I am hidden" on a new line at the end of the
h.html file using the command cat (Hint: explore the difference between
> and >>).
5. Read the file h.html in the web browser. Can you see the new text
you added? Why? (Hint: look at the file using a text editor or a text
viewer and try to guess the answer based on the tags in HTML).
6. Can you find a command that will tell you the type of the file
h.html? (Hint: try to use apropos with different keywords and grep to
further filter the output, e.g. "apropos type | grep tree")
What is the meaning of "|" (Hint: look into the bash manual)? Take a
closer look at the manual of the grep command, that is really very
useful.
7. Try to figure out how many html new lines are in the file h.html
without counting them by hand (Hint: the html representation of newline
can be <br> or <BR>).
To solve this problem try to use grep with the output filtered by a
command for counting. Is it possible to do it just by using grep alone
with the right options?
8. In one terminal get a remote command prompt on another qwe
computer (Hint: use ssh). In a second terminal run a top command on a
different qwe computer.
In a third terminal try to figure out how many ssh sessions and top
processes are you running on the local computer (Hint: try top, pstree,
and ps filtered by grep to monitor processes and observe which
alternative is better for different tasks).
9. In a fourth terminal get a remote command line to the same computer
that runs top. How can you kill the top process? (Hint: try to do it
using kill or using another top - isn't it amazing that you can run two
instances of the same command on the same computer?)
10. Create a symbolic link of the file h.html into index.html. Use ls
-l to see how is the symbolic link listed and what size does it have.
11. How can you run a top command on a remote computer while getting
back the command prompt on the local computer? (Hint: look at the
options of ssh and xterm)