Problem

In this hands-on project, you use the shell to redirect the stdout and stderr to a file...

In this hands-on project, you use the shell to redirect the stdout and stderr to a file and take stdin from a file.

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 touch sample1 sample2 and press Enter to create two new files named sample1 and sample2 in your home directory. Verify their creation by typing ls –F at the command prompt and press Enter.

3. At the command prompt, type ls -l sample1 sample2 sample3 and press Enter. Is there any stdout displayed on the terminal screen? Is there any stderr displayed on the terminal screen? Why?

4. At the command prompt, type ls -l sample1 sample2 sample3 > file and press Enter. Is there any stdout displayed on the terminal screen? Is there any stderr displayed on the terminal screen? Why?

5. At the command prompt, type cat file and press Enter. What are the contents of file and why?

6. At the command prompt, type ls -l sample1 sample2 sample3 2> file and press Enter. Is there any stdout displayed on the terminal screen? Is there any stderr displayed on the terminal screen? Why?

7. At the command prompt, type cat file and press Enter. What are the contents of file and why? Were the previous contents retained? Why?

8. At the command prompt, type ls -l sample1 sample2 sample3 > file 2>file2 and press Enter. Is there any stdout displayed on the terminal screen? Is there any stderr displayed on the terminal screen? Why?

9. At the command prompt, type cat file and press Enter. What are the contents of file and why?

10. At the command prompt, type cat file2 and press Enter. What are the contents of file2 and why?

11. At the command prompt, type ls -l sample1 sample2 sample3 > file 2>&1 and press Enter. Is there any stdout displayed on the terminal screen? Is there any stderr displayed on the terminal screen? Why?

12. At the command prompt, type cat file and press Enter. What are the contents of file and why?

13. At the command prompt, type ls -l sample1 sample2 sample3 >&2 2>file2 and press Enter. Is there any stdout displayed on the terminal screen? Is there any stderr displayed on the terminal screen? Why?

14. At the command prompt, type cat file2 and press Enter. What are the contents of file2 and why?

15. At the command prompt, type date > file and press Enter.

16. At the command prompt, type cat file and press Enter. What are the contents of file and why?

17. At the command prompt, type date >> file and press Enter.

18. At the command prompt, type cat file and press Enter. What are the contents of file and why? Can you tell when each date command was run?

19. At the command prompt, type tr o O /etc/hosts and press Enter. What error message do you receive and why?

20. At the command prompt, type tr o O

21. 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
Solutions For Problems in Chapter 7