CLI Flashcards
What is Bash?
Bash is an sh-compatible shell that allows us to run complex commands and perform different tasks from a terminal window. It incorporates useful features from both the KornShell and C shell.
How to view content of given enviroment variables?
echo $PATH
Useful enviroment variables
$USER
$PWD
$HOME
How to display the process ID of the current shell instance?
echo “$$”
What “export” command does?
The export command makes the variable accessible to any subprocesses we might spawn from our current Bash instance. If we set an environment variable without export it will only be available in the current shell.
How to view enviroment variables defined by default in Linux?
By env command.
How to check history of commands that have been entered?
By history command.
How to re-run first command from your history?
!1
How to repeat last command that was executed during terminal session?
!!
Where is command history saved to?
.bash_history in the user home directory.
Two enviroment variables control the history size
HISTSIZE and HISTFILESIZE
HISTSIZE
Controls the number of commands stored in memory for the current session.
HISTFILESIZE
Configures how many commands are kept in the history file.
How to invoke reverse-i-search facility?
CTRL + R
How to inspect your bash history?
By history command
How to use history expansion to re-run a command from it?
!number
Standard Input (STDIN)
Data fed into the program
Standard Output (STDOUT)
Output from the program (defaults to terminal)
Standard Error (STDERR)
Error messages (defaults to terminal)
Standard Error (STDERR)
Error messages (defaults to terminal)
Piping operator
|
Redirection Operators
<>
Which operator is used to save the output to a file to keep it for future?
>
How to save “test” string to file “redirection_test.txt”?
echo “test” > redirection_test.txt