Chapter 9: Writing Scripts, Configuring Email, and Using Databases Flashcards
What’s an environment variable?
They’re used to store information on a system to make it easier to run programs.
How do you manually set an environment variable?
<b>$HOSTNAME=carson.example.com
$export HOSTNAME</b>
Now that HOSTNAME is available to subshells.
What’s a subshell?
A child process created by the shell or a shell script when a program is initiated.
How can you examine a specific environment variable?
<b>echo $HOSTNAME</b>
How can you see a list of ALL environment variables?
<b>env, set, </b>or <b>printenv</b>
What happens by default if you set a new environment variable and then log out?
It goes away. They are not persistent by default.
How do you get a program to run in the background?
Append an ampersand (&) after typing its name.
What’s an alias?
It’s a new name that you give a regular command. This can make it easier to remember the names of more obscure programs.
This can also help you run a command along with specific options that you like to use, such as <b>ls -alF</b>
How do you implement an alias in bash script?
<b>alias <i>alias_name</i>=”command”</b>
How do you remove an alias you’ve set using bash?
Same way, but use the <b>unalias</b> command
What configuration file do you use for keyboard customization?
<b>/etc/inputrc</b>-Global
<b>~/.inputrc</b>-User
What denotes a comment line in a bash script?
A pound sign; <b>#</b>
What does it mean to “source” a script you’re running?
You run that script from its source. This requires a new shell instance (subshell).
Positional Parameters
These are variables that are passed to the script. $0 is the script name, $1 is the first variable, $2 the second, up to $9.