WK2 LAB Examine input and output in the shell Flashcards

1
Q

Task 1. Generate output with the echo command

A

The echo command in the Bash shell outputs a specified string of text. In this task, you’ll use the echo command to generate output in the Bash shell.

Type echo hello into the shell and press ENTER.
The hello string should be returned:

hello
The command echo hello is the input to the shell, and hello is the output from the shell.

Rerun the command, but include quotation marks around the string data. Type echo “hello” into the shell and press ENTER.
The hello string should be returned again:

hello
Note: The output is the same as before. The quotation marks are optional in this case, but they tell the shell to group a series of characters together. This can be useful if you need to pass a string that contains certain characters that might be otherwise misinterpreted by the command.
Use the echo command to output your name to the shell.
Type echo “name” into the shell, replacing “name” with your own name, and press ENTER.

The name you’ve entered as the string should return as the output.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Task 2. Generate output with the expr command

A

In this task, you’ll use the expr command to generate some additional output in the Bash shell. The expr command performs basic mathematical calculations and can be useful when you need to quickly perform a calculation.

Imagine that the system has shown you that you have 32 alerts, but only 8 required action. You want to calculate how many alerts are false positives so that you can provide feedback to the team that configures the alerts.

To do this, you need to subtract the number of alerts that required action from the total number of alerts.

Calculate the number of false positives using the expr command.
Type expr 32 - 8 into the shell and press ENTER.

The following result should be returned:

24
Note: The expr command requires that all terms and operators in an expression are separated by spaces. For example: expr 32 - 8, and not expr 32-8.
Now, you need to calculate the average number of login attempts that are expected over the course of a year. From the information you have, you know that an average of 3500 login attempts have been made each month so far this year.

So, you should be able to calculate the total number of logins expected in a year by multiplying 3500 by 12.

Type expr 3500 * 12 into the shell and press ENTER.
The correct result should now be returned:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Task 3. Clear the Bash shell

A

In this task, you’ll use the clear command to clear the Bash shell of all existing output. This allows you to start with the cursor at the top of the Bash shell window.

When you work in a shell environment, the screen can fill with previous input and output data. This can make it difficult to process what you’re working on. Clearing the screen allows you to create a clutter-free text environment to allow you to focus on what is important at that point in time.

Type clear into the shell and press ENTER.
Note: All previous commands and output will be cleared, and the user prompt and cursor will return to the upper left of the shell window.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Genreal commands for this lab

A

You have multiple tasks in this lab:

Generate output in the shell the echo command

Perform basic calculations the expr command

Clear the shell window the clear command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly