Chapter 9: Writing Scripts, Configuring Email, and Using Databases Flashcards

1
Q

What’s an environment variable?

A

They’re used to store information on a system to make it easier to run programs.

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

How do you manually set an environment variable?

A

<b>$HOSTNAME=carson.example.com
$export HOSTNAME</b>

Now that HOSTNAME is available to subshells.

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

What’s a subshell?

A

A child process created by the shell or a shell script when a program is initiated.

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

How can you examine a specific environment variable?

A

<b>echo $HOSTNAME</b>

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

How can you see a list of ALL environment variables?

A

<b>env, set, </b>or <b>printenv</b>

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

What happens by default if you set a new environment variable and then log out?

A

It goes away. They are not persistent by default.

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

How do you get a program to run in the background?

A

Append an ampersand (&) after typing its name.

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

What’s an alias?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you implement an alias in bash script?

A

<b>alias <i>alias_name</i>=”command”</b>

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

How do you remove an alias you’ve set using bash?

A

Same way, but use the <b>unalias</b> command

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

What configuration file do you use for keyboard customization?

A

<b>/etc/inputrc</b>-Global

<b>~/.inputrc</b>-User

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

What denotes a comment line in a bash script?

A

A pound sign; <b>#</b>

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

What does it mean to “source” a script you’re running?

A

You run that script from its source. This requires a new shell instance (subshell).

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

Positional Parameters

A

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.

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