Bash - Unix Shell/Linux CLI Flashcards
(9 cards)
What is an exit status (message/number) in Bash? $?
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.
What does grep do?
grep searches for a given string and outputs all those X that contains the given string “ “.
What does this command show: tail -n 10 /var/log/syslog ?
Shows the last 10 lines of the file /var/log/syslog — in your terminal.
What’s the difference between > and»_space; in Bash?
> 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”.
What does the env or printenv command do in Bash?
env = displays current environment variables.
What is fi in Bash?
fi is the keyword that closes an if statement block in Bash scripting, marking the end of the conditional.
What is done in Bash?
done marks the end of a loop block (such as for, while, or until) in Bash scripting.
What is do in Bash?
do marks the beginning of the commands to execute inside a loop (for, while, or until) in Bash scripting.
What is df in Bash?
df (disk free) is a command that displays the amount of disk space used and available on mounted filesystems.