1.1 The Shell Flashcards
What is a shell?
The Command Line Interface (CLI) or Text User Interface (TUI) that administrators use to control a Linux operating system. Users and programs use the shell to send commands to the system. A shell might be opened inside a Graphical User Interface (GUI), or might be the sole method used to run the computer.
What are the common shells?
- bash - Bourne-Again Shell
- sh - Bourne Shell
- ksh - Korn Shell
- csh - C Shell
- tcsh - TC Shell
Features of bash
- *bash** - The Bourne-again shell - The standard shell used in most Linux computers. It uses commands similar to a UNIX shell. Bash includes features such as:
- Command completion when pressing the tab key
- Command history
- Improved arithmetic functions
Features of ksh
ksh - The Korn shell - Developed by David Korn. Ksh has scripting features not found in bash.
Common characteristics of all shells
- A Linux system can use multiple shells at the same time.
- A list of shells is stored in the /etc/shells file.
- All shells are interfaces with the kernel, separate and distinct from it.
- Shells are run both interactively by end users and automatically by the computer’s processes.
- Shells can run within one another either interactively when a user starts a second shell from the first shell’s command line, or automatically by scripts or programs.
- Shells use configuration files to establish their operating environments.
How do you get into the shell?
- Boot into it at run level 3 (no GUI)
- Access it through a terminal window using a terminal application within the GUI
What is the difference between how a Linux shell recognizes the path to executable programs compared to how a DOS environment recognizes the path?
- In DOS or Windows, the shell searches for your command in the current directory first, followed by the directories in the PATH variable.
- In Linux, the shell only searches the directories in the PATH variable for your command. It does not search the current directory.
How can you execute commands that are not in the PATH environment variable?
- Use an absolute path
- Use a relative path
- Copy or move the command file to a directory that is in the path (like ~/bin or /bin)
- Add the directory that contains the command file to the PATH variable
How can you execute commands in the current working directory?
Prefix the command with a “dot-slash” (./)
What types of items can Tab complete be used to complete once you start typing the entities’ name?
Files and directories.
What is tab-completion?
A shell feature that gives you the ability to type part of a filename and then have the shell complete the filename (or provide a list of matching suggestions) by hitting the tab key.
How does command history work?
Every time you enter a command, that command is written to a hidden file in your home directory. You can access previous commands with the up- and down-arrow keys.
What common commands are used to navigate through shells?
- ‘pwd’
- ‘ls’
- ‘cd’
Which file contains the history of shell commands?
~/.bash_history
What does the tilde symbol (~) in the command prompt represent?
The tilde symbol (~) in the prompt indicates the present working directory is the home directory of the current user.
What is the command path?
The set of directories in which Linux searches to find executable files for the commands typed into the shell prompt:
- The path does not include the present working directory.
- To see the path, type echo $PATH.
- To add a directory to a path, type PATH=$PATH:.
How do you execute programs in the shell?
- Type the executable name in the present working directory if the program is in the command path.
- Type ./filename to run an executable in the present working directory. (./ indicates the present working directory.)
- Type the full pathname to the file to run an executable from anywhere.
Are filenames and paths case-sensitive?
Yes
How does tab-completion work?
Type the beginning of the name, then press Tab to complete a file, command, or directory name. (Press Tab twice if there is more than one possible file, command, or directory name.)
How do you recall the previous command and scroll through all previous commands?
Press the up arrow at the command prompt to print the last command. Press it again to scroll through all previous commands.
What does the pwd command do?
Shows the present working directory.
What does the whoami command do?
Displays the current username.
What does the uname command do?
uname prints system information.
What does the command uname -a do?
uname -a prints all system information.