Problem

In this hands-on project, you use and protect shell metacharacters. 1. Switch to a comm...

In this hands-on project, you use and protect shell metacharacters.

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

2. At the command prompt, type date; who and press Enter to run the date command immediately followed by the who command. Use the information in Table 2-8 to describe the purpose of the ; metacharacter.

3. At the command prompt, type echo This is OK and press Enter to display a message on the terminal screen.

4. At the command prompt, type echo Don’t do this and press Enter. Which character needs to be protected in the previous command? Press the Ctrl and c keys together to cancel your command and return to a BASH shell prompt.

5. At the command prompt, type echo “Don’t do this” and press Enter. What is displayed on the terminal screen?

6. At the command prompt, type echo Don\’t do this and press Enter. What is displayed on the terminal screen?

7. At the command prompt, type echo $SHELL and press Enter to view the expansion of a variable using a shell metacharacter. What is displayed on the terminal screen? Next, type echo $TEST and press Enter to find out what happens when a variable that does not exist is used in a command. What is displayed?

8. At the command prompt, type echo You have $4.50 and press Enter. What is displayed? Why? Which character needs to be protected in the previous command? What are two different ways that you can protect this character from interpretation by the shell?

9. At the command prompt, type echo ‘You have $4.50’ and press Enter. What is displayed on the terminal screen? Did the single quotation marks protect this metacharacter from shell interpretation?

10. At the command prompt, type echo “You have $4.50” and press Enter. What is displayed on the terminal screen? Did the double quotation marks protect this metacharacter from shell interpretation?

11. At the command prompt, type echo You have \$4.50 and press Enter. What is displayed on the terminal screen? Did the backslash protect this metacharacter from shell interpretation?

12. At the command prompt, type echo My name is ‘whoami‘ and press Enter. What function do back quotes perform?

13. 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 2