Chapter 3: Command Line Fun Flashcards
How do you view the PATH variable?
echo $PATH
How do you view the USER variable?
echo $USER
How do you view the HOME variable?
echo $HOME
What is the export command?
The export command defines a variable.
Why is the export command useful?
If we don’t want to repeatedly type out some sort of string, for example an IP address, the export command allows us to define a variable.
How do you define a variable using export?
E.g. export b=192.168.116.114
How do you then use that variable in a practical example?
ping -c 10 $b
The variable must have a $ accompanying it.
What command and variable do we use to view the current PID (Process ID) of the bash shell?
echo “$$”
How do we view all environment variables?
env
How do we view command history?
history
After viewing the history, what is a fast way to execute a command?
Using the numbers next to the command, type !3 (for example).
Where is all command history saved?
In the .bash_history file.
What two variables dictate the command history save?
HISTSIZE and HISTFILESIZE
What does HISTSIZE do?
Controls the number of commands kept for the current session.
What does HISTFILESIZE do?
Configures how many commands are kept in the overall history file.
Where are HISTSIZE and HISTFILESIZE stored?
.bashrc - bash configuration file
How do we use the reverse-i-search facility?
Ctrl + R
What are the three data streams connected to the programs run through bash?
Standard Input (STDIN) Standard Output (STDOUT) Standard Error (STDERR)
How is piping related to the data streams?
Piping connects the data streams between programs and files.
What command counts the words and lines of a document?
wc
What is the command for counting the number of lines in a document?
wc -l
What is the command for counting the number of characters in a document?
wc -m
How do you create a new document through redirecting data streams?
echo “hello bob” > redirection.txt
How do you append data using data streams?
echo “hello jane”»_space; redirection.txt