Problem

In this hands-on project, you display file contents using the cat, tac, head, tail, stri...

In this hands-on project, you display file contents using the cat, tac, head, tail, strings, and od commands.

1. Switch to a command-line terminal (tty2) by pressing Ctrl+Alt+F2 and log in to the terminal using the user name of root and the password of secret.

2. At the command prompt, type cat /etc/hosts and press Enter to view the contents of the file hosts, which reside in the directory /etc. Next, type cat –n /etc/hosts and press Enter. How many lines does the file have? At the command prompt, type tac /etc/hosts and press Enter to view the same file in reverse order. The output of both commands should be visible on the same screen. Compare them.

3. To see the contents of the same file in octal format instead of ASCII text, type od /etc/hosts at the command prompt and press Enter.

4. At the command prompt, type cat /etc/inittab and press Enter.

5. At the command prompt, type head /etc/inittab and press Enter. What is displayed on the screen? How many lines are displayed, which ones are they, and why?

6. At the command prompt, type head -5 /etc/inittab and press Enter. How many lines are displayed and why? Next, type head -3 /etc/inittab and press Enter. How many lines are displayed and why?

7. At the command prompt, type tail /etc/inittab and press Enter. What is displayed on the screen? How many lines are displayed, which ones are they, and why?

8. At the command prompt, type tail -5 /etc/inittab and press Enter. How many lines are displayed and why? Type the cat –n /etc/inittab command at a command prompt and press Enter to justify your answer.

9. At the command prompt, type file /bin/nice and press Enter. What type of file is it? Should you use a text tool command on this file?

10. At the command prompt, type strings /bin/nice and press Enter. Notice that you are able to see some text within this binary file. Next, type strings /bin/nice | more to view the same content page-by-page. When finished, press q to quit the more command.

11. Type exit and press Enter to log out of your shell

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search