Bash - Unix Shell/Linux CLI Flashcards

(9 cards)

1
Q

What is an exit status (message/number) in Bash? $?

A

An exit status is a numeric code a command returns after execution ($?), where 0 means success and any non-zero value indicates an error or failure.

So if you: echo $?
Output: 234
Then the last command you ran failed with an error code: 234.

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

What does grep do?

A

grep searches for a given string and outputs all those X that contains the given string “ “.

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

What does this command show: tail -n 10 /var/log/syslog ?

A

Shows the last 10 lines of the file /var/log/syslog — in your terminal.

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

What’s the difference between > and&raquo_space; in Bash?

A

> redirects output to a file, overwriting existing content and creating a new file if not in existence already.
> appends output to the end of a file without overwriting it’s contents.

So: echo “overwritten” > fileOld.txt
Will overwrite/replace all fileOld.txt content with “overwritten”.

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

What does the env or printenv command do in Bash?

A

env = displays current environment variables.

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

What is fi in Bash?

A

fi is the keyword that closes an if statement block in Bash scripting, marking the end of the conditional.

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

What is done in Bash?

A

done marks the end of a loop block (such as for, while, or until) in Bash scripting.

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

What is do in Bash?

A

do marks the beginning of the commands to execute inside a loop (for, while, or until) in Bash scripting.

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

What is df in Bash?

A

df (disk free) is a command that displays the amount of disk space used and available on mounted filesystems.

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