Chapter 9 - Writing Scripts, Configuring Email, & Using Databases Flashcards

1
Q

what do environmental variables provide?

9-454

A

the means to pass named data to programs launched from a shell or a subshell

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

what is a subshell?

9-454

A

a child process that is created by either 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
3
Q

you’ve set an environment variable manually via an equal-sign assignment operator. what command must you use to make that variable to subshells?

9-455

A

the export command

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

how can you find out how environment variables are configured? (what do you type?)

9-455

A

env, set, or printenv

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

if you want to know the value of one variable, you can use the echo command, but how do you use it?

9-458

A

echo $variable

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

tell me 3 times when you would use an alias

9-459

A
  1. to assign names that are easier to remember in order to obscure commands
  2. to implement desirable command options as a command’s default
  3. to create a shortened version of a command to minimize typing
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

you are configuring shells via shell configuration files. tell me the 2 ways they are classified (4 combinations).

9-460

A

whether they are global or user files and whether they have login or non-login file locations

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

how can you see your current key bindings?

9-462

A

bind -p

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

true/false: most minux systems use bash by default

9-462

A

true

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

you are looking at a shell script. what tells the linux kernel that it is a shell script?

9-463

A

it begins with a #!

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

tell me 6 commands that are commonly used in scripts

9-464,465

A
file manipulation commands (ls, mv, cp, rm)
grep
find
cut
sed
echo
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

is it possible to set a script’s SUID (SGID bits)?

9-465

A

yes

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

when you type the script’s name, preceded by bash, what does that do?

9-466

A

it tells linux to run the script in the current directory rather than searching the current path

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

what is a script?

9-462

A

a simple program written in an interpreted computer language that’s embedded in the linux shell, used for repetitive tasks

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

typing the script’s name, preceded by ./, tells linux what?

9-466

A

tells linux to run the script in the current directory rather than searching the current path

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

when would you type the script’s full path and name?

9-467

A

when the script is not located in your current working directory

17
Q

typing in the script’s names requires the shell script to be moved to what?

9-467

A

moved to a directory on your path

18
Q

typing the script’s name, preceded by sh, does what?

9-468

A

tells linux to run the script in the current directory rather than searching the current path

19
Q

what happens when you type the source keyword before the script name?

is a subshell created to run the script?

9-468

A

it tells the bash shell to use a method type called sourcing.

no

20
Q

typing a dot and a space before the script name does what?

9-469

A

tells the bash shell to use the sourcing method type

21
Q

what does exec ./ script-name do?

does it need execute permission set on the file?

9-469

A

method for executing a file

yes

22
Q

when you are using variables in shell scripts, what is a variable?

9-470

A

a placeholder in a script for a value that will be determined when the script runs

23
Q

variables that are passed to the script are frequently called what?

9-471

A

positional parameters

24
Q

tell me two places where a user defined variable can be used.

9-474

A

within a script

at the command line

25
Q

when do you use / not use the dollar sign with a variable (environment or user defined)?

9-474

A

use the dollar sign if you’re doing anything WITH the variable, don’t use it if you’re doing anything TO the variable