OS515-Workbook6 Flashcards
The default shell in Red Hat Enterprise Linux is…?
the bash shell.
The bash shell can be used…?
interactively, or as a powerful scripting language.
Upon startup, bash executes commands found in….?
the ~/.bashrc file, allowing users to customize their shell.
The bash shell maintains a history of…?
the command lines that it executes. Command lines can be retrieved from the history using various history expansions that begin with “!”.
See slide 3 for..?
command history.
Multiple commands can be separated with a…?
; (see example on slide 4)
The first line of your script must specify…?
which interpreter to send instructions to.
Before ou can run a script, you must…?
enable the “executable” permission on it (otherwise it’s just a text file).
If you created a script called foo.sh in your home directory and then just typed foo.sh you would get a….?
“no such file or directory” error.
Bash shell script example slide…?
6
Upon exiting, every command returns an integer to its parent called…?
a return value. (Examples on slide 7)
The shell variable $? expands to the return value of…?
previously executed command. (Examples on slide 7)
Running Multiple Commands Conditionally:
&& and || conditionally…?
separate multiple commands. (Example on slide 8)
TASK:
Write a script that will
- Create an empty file called testfile in your home directory.
- Copy the file to the /tmp directory and delete the copy on your home directory of the copy completes successfully.
How do you ensure the scripts runs?
Where to put the script so you can run it?
(DO IT YOURSELF)
Shell variables are assigned using an…?
A=apple syntax
Variables are examined (“dereferenced”) with the …?
$ character as in echo $A.
At the kernel level, every process has a collection of environment variables, which are inherited by…?
child processes.
The export command converts a shell variable into…?
an environment variable.
The set and env commands list…?
shell variables and environment variables, respectively.
Bash Variables:
The variable ? expands to…?
The exit status of the most recently executed command.
Bash Variables:
The variable - expands to…?
Currently enabled shell option flags.
Bash Variables:
The variable $ expands to…?
Process id (pid) of current shell.
Bash Variables:
The variable ! expands to…?
Process id (pid) of most recent background command.
Bash Variables:
The variable _ expands to…?
Last token of previous command.
Bash Variables:
The variable PPID expands to…?
The process id (pid) of the shell’s parent.
Bash Variables:
The variable SHELLOPTS expands to…?
Colon separated list of currently enabled shell options, as reported by the set -o command.
Bash Variables:
The variable UID expands to…?
The userid of the current user.
Bash Variables:
The variable BASH_VERSION expands to…?
The current bash version.