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

Project 7-1

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. Boot your Fedora Linux virtual machine. After your Linux system has been loaded, switch to a command-line terminal (tty5) by pressing Ctrl+Alt+F5 and log in to the terminal using the user name of root and the password of LINUXrocks!.

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 the 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 the file and why? Were the previous contents retained? Why?

  1. 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?

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

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

  4. 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?

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

  6. 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?

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

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

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

    file and why?

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

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

    file and why? Can you tell when each date command was run?

  12. At the command prompt, type tr o O /etc/hosts and press Enter. What error

    message do you receive and why?

  13. At the command prompt, type tr o O

    and why?

  14. At the command prompt, type tr o O <

    prompt, type oranges and press Enter. Next, type Toronto and press Enter, type Donkey Kong and press Enter, and then type EOF and press Enter. Note the output. What is this type of input redirection called?

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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!