Introduction to Bash Flashcards Preview

Networking > Introduction to Bash > Flashcards

Flashcards in Introduction to Bash Deck (28):

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....?



In Linux, the shell is the most commonly used program. The shell is what you see when you...?

log in or open a terminal, and is what you use to start most every command.

(Although there are a variety of different shells available, they all provide the same basic behavior: listen for commands from the user, start processes as specified in those commands, and report the results back to the user)


The most commonly used shell in Linux is the bash shell, which is the default shell in...?

Red Hat Enterprise Linux.


Shell scripts allow users to automate often repeated actions by combining a series of...?



Unlike interactive shells, shell scripts usually run a series of commands...?

non-interactively, and many of the features of the bash shell provide programming logic (such as branches or loops) for writing sophisticated scripts.


In practice, users seldom need to start a shell...?

manually. Whenever someone logs in, or opens a terminal, a shell is started automatically.


Occasionally, however, users would like to run a different shell, or another instance of the same shell. Because the shell is "just another" program, new shells can be launched from an existing shell. The new shell is referred to as a...?

subshell of the original shell.


When the subshell is exited, control is returned to the ...?

original shell.


When starting a bash subshell, the apparent differences between the subshell and the parent shell are...?

minimal, and care must be taken to keep track of which shell you are in.


As part of its initialization, the bash shell will look for a file titled...?

.bashrc in a user's home directory. This file is used to customize the bash shell.

(As the shell starts, commands listed in this file are executed as if they were entered on the command line. Technically, the bash shell "sources" the file. )


Interactive shells continuously repeat a cycle of listening for a...?

command line, evaluating the requested command and performing any requested actions, and displaying the results


The shell listens to the keyboard for input, and uses the RETURN key to recognize the...?

end of input.


As a convenience to users of interactive shells, the bash shell keeps a history of each command entered by the user, and provides a variety of ways to make commands from this history available at the finger tips. The easiest way to view your current history is to use the......?

history command.


As an alternative to the arrow keys, the bash shell also performs "history substitution", which is triggered by...?

the exclamation point.


Bash History Substitution:
Syntax: !!
Substitution: ????

Previous Command.


Bash History Substitution:
Syntax: !n
Substitution: ????

Command number n


Bash History Substitution:
Syntax: !-n
Substitution: ????

The nth most recent command.


Bash History Substitution:
Syntax: !cmd
Substitution: ????

The most recent command that began cmd


Not only does the bash shell maintain a command history within a session, but the shell also preserves command histories between sessions. When the bash shell exits, it dumps the current command history into a file called....?

.bash_history in a user's home directory. Upon startup, the shell initializes the command history from the contents of this file.

(What repercussions does this have for multiple interactive shells (owned by the same user) running at the same time? Because the history is only saved to disk as the shell exits, commands executed in one bash process are not available in the command history of a simultaneously running bash process. Also, the last shell to exit will overwrite the histories of any shells that exited previously.)


Bash Shell Command History Variables
Variable: HISTFILE
Default Value: ~/.bash_history
Effects: ?????

The file to which the command history is saved on exit and from which it is initialized on startup.


Bash Shell Command History Variables
Default Value: 1000
Effects: ?????

The file HISTFILE will be truncated to this size on startup.


Bash She Command History Variables
Variable: HISTSIZE
Default Value: 1000
Effects: ????

The maximum number of commands that willl be written to teh file HISTFILE on exit.


ESC+. and ALT+. ....?

The last token of the previously typed command line can be recovered with these two commands.

. Once learned, this little trick comes in handy surprisingly often. The last token of a command often represents the object that someone is handling. For example, someone might make a directory, and then immediately cd to it, or edit a file, and immediately want to use chmod to change its permissions. If the key sequence is repeated, the bash shell will continue to cycle through the last tokens of earlier command lines.


CTRL+R ...?

This key sequence mimics !cmd in spirit. Text typed after the CTRL+R key sequence is matched against previously typed commands, with the added advantage that matching command lines are viewed immediately as the text is typed. You also have the opportunity to edit the recalled line (using the LEFT and RIGHT arrow keys, or other command line editing keystrokes) before executing the command.


fc ...?

The fc command allows users to "fix" the previously entered command, by opening up the user's default editor (vi by default) with the previously entered command as text. Upon exiting the editor (presumably after somehow editing the command), the new text will be immediately executed. For those proficient in quickly exiting an editor, the command comes in handy.