Redhat Chapter 2 Flashcards
is a text-based interface which can be used to input instructions to a computer system.
command line
The Linux command line is provided by a program called the _______
shell
The default shell for users in Red Hat Enterprise Linux is the __________.
GNU Bourne-Again Shell (bash)
is an improved version of one of the most successful shells used on UNIX-like systems, the Bourne Shell (sh).
Bash
When a shell is used interactively, it displays a string when it is waiting for a command from the user. This is called the _________.
shell prompt
When a regular user starts a shell, the default prompt ends with a ________ character
$
example:
[user@host ~]$
The $ character is replaced by a ________ character if the shell is running as the superuser, root.
#
example:
[root@host ~]#
The $ character is replaced by a # character if the shell is running as the superuser, ________.
root
The root is a __________ shell, which helps to avoid accidents and mistakes which can affect the whole system.
superuser
Using ________ to execute commands can be powerful.
bash
The bash shell provides a ________ language that can support automation of tasks.
scripting
The ________ has additional capabilities that can simplify or make possible operations that are hard to accomplish efficiently with graphical tools.
shell
The ________ shell is similar in concept to the command-line interpreter found in recent versions of Microsoft Windows, cmd.exe, although it has a more sophisticated scripting language.
bash
Administrators using the Apple Mac who use the Terminal utility may be pleased to note that ________ is the default shell in macOS.
bash
Shell Basics
Commands entered at the shell prompt have three basic parts:
- Command
- Options
- Arguments
is the name of the program to run.
- Command
- Options
- Arguments
Command
The command may be followed by one or more ________, which adjust the behavior of the command or what it will do. It normally starts with one or two dashes (-a or –all, for example).
- Command
- Options
- Arguments
Options
Commands may also be followed by one or more ________, which often indicate a target that the command should operate upon.
- Command
- Options
- Arguments
Arguments
Identify the command, option, and argument in the command (example):
usermod -L user01
Command:
usermod
Option:
-L
Argument:
user01
(The effect of this command is to lock the password of the user01 user account.)
To run the shell, you need to log in to the computer on a terminal ________.
terminal
A ________is a text-based interface used to enter commands into and print output from a computer system.
terminal
The computer might have a hardware keyboard and display for input and output directly connected to it. This is the Linux machine’s physical console ________.
physical console
The physical console supports multiple ________, which can run separate terminals and supports an independent login session.
virtual consoles
You can switch between virtual consoles by pressing ________ and a function key (F1 through F6) at the same time.
Ctrl+Alt
The computer might provide a graphical login prompt on one of the virtual consoles. You can use this to log in to a ________.
graphical environment
In Red Hat Enterprise Linux 8, if the graphical environment is available, the login screen will run on the first virtual console, called ________. Five additional text login prompts are available on virtual consoles two through six.
tty1
Many system administrators choose not to run a graphical environment on their servers. This allows resources which would be used by the graphical environment to be used by the server’s services instead. (True or False)
T
is a menu item used to switch users in the graphical environment without logging out
Switch User
When you log out of a graphical environment, it will exit and the ________ will automatically switch back to the graphical login screen on the first virtual console.
physical console
In Red Hat Enterprise Linux 6 and 7, the graphical login screen runs on the first virtual console, but when you log in your initial graphical environment ________ the login screen on the first virtual console instead of starting on a new virtual console.
- hides
- replaces
- removes
- opens
replaces
In Red Hat Enterprise Linux 5 and earlier, the first six virtual consoles always provided ________ prompts.
text login
If the graphical environment is running, it is on virtual console seven (accessed through ________ ).
Ctrl+Alt+F7
A ________ server does not have a keyboard and display permanently connected to it.
headless
A ________ may be filled with many racks of headless servers, and not providing each with a keyboard and display saves space and expense.
data center
To allow administrators to log in, a headless server might have a login prompt provided by its ________, running on a serial port which is connected to a networked console server for remote access to the serial console.
serial console
would normally be used to fix the server if its own network card became misconfigured and logging in over its own network connection became impossible.
serial console
In a modern computing environment, many ________ are actually virtual machines or are running as public or private cloud instances.
headless servers
In Linux, the most common way to get a shell prompt on a remote system is to use ________.
Secure Shell (SSH)
Most Linux systems (including Red Hat Enterprise Linux) and macOS provide the OpenSSH command-line program ________ for aquiring a shell prompt.
ssh
In this example, a user with a shell prompt on the machine host uses ssh to log in to the remote Linux system remotehost as the user remoteuser:
[user@host ~]$ ssh remoteuser@remotehost
remoteuser@remotehost’s password: password
[remoteuser@remotehost ~]$
The ________ command encrypts the connection to secure the communication against eavesdropping or hijacking of the passwords and content.
ssh
Some systems (such as new cloud instances) do not allow users to use a password to log in with ssh for tighter security. (True or False)
T
An alternative way to authenticate to a remote machine without entering a password is through ________.
public key authentication
With public key authentication method, users have a special identity file containing a ________, which is equivalent to a password, and which they keep secret.
private key
Their account on the server is configured with a matching public key, which does not have to be secret.
When logging in, users can configure ________ to provide the private key and if their matching public key is installed in that account on that remote server, it will log them in without asking for a password.
ssh
When logging in, users can configure ________ to provide the private key and if their matching public key is installed in that account on that remote server, it will log them in without asking for a password.
ssh
Example (using ssh command):
a user with a shell prompt on the machine host logs in to (remotehost) as (remoteuser) using ssh, using public key authentication. The (-i) option is used to specify the user’s private key file, which is (mylab.pem). The matching public key is already set up as an authorized key in the (remoteuser) account.
(First line)
[user@host ~]$ ssh -i mylab.pem remoteuser@remotehost
(Second line)
[remoteuser@remotehost ~]$
For this to work, the private key file must be readable only by the user that owns the file. In the preceding example, where the private key is in the mylab.pem file, the command chmod 600 mylab.pem could be used to ensure this. How to set file permissions is discussed in more detail in a later chapter.
Each time you connect to a remote host with ssh, the remote host sends ssh its ________ to authenticate itself and to help set up encrypted communication.
host key
The ssh command compares that against a list of saved host keys to make sure it has changed. (True of False)
The ssh command compares that against a list of saved host keys to make sure it has not changed.
In SSH, ________ protect against man-in-the-middle attacks, these host keys are unique for each server, and they need to be changed periodically and whenever a compromise is suspected.
host keys
The ssh command compares that against a list of saved host keys to make sure it has not changed. If the host key has changed, this might indicate that someone is trying to pretend to be that host to hijack the connection which is also known as ________.
man-in-the-middle attack
If the local machine does have a host key saved and it does not match the one actually sent by the remote host, the connection will automatically be ________ with a warning.
closed
When you are finished using the shell and want to quit, you can choose one of several ways to end the session. You can enter the ________ command or press _______ to terminate the current shell session
- exit
- Ctrl+D
The following is an example of a user logging out of an SSH session:
[remoteuser@remotehost ~]$ exit
logout
Connection to remotehost closed.
[user@host ~]$
Which term describes the interpreter that executes commands typed as strings?
A) Command
B) Console
C) Shell
D) Terminal
C) Shell
Which term describes the visual cue that indicates an interactive shell is waiting for the user to type a command?
A) Argument
B) Command
C) Option
D) Prompt
D) Prompt
Which term describes the hardware display and keyboard used to interact with a system?
A) Physical Console
B) Virtual Console
C) Shell
D) Terminal
A) Physical Console
Which term describes one of multiple logical consoles that can each support an independent login session?
A) Physical Console
B) Virtual Console
C) Shell
D) Terminal
B) Virtual Console
Which term describes an interface that provides a display for output and a keyboard for input to a shell session?
A) Physical Console
B) Virtual Console
C) Shell
D) Terminal
D) Terminal
is the graphical user interface on a Linux system.
desktop environment
provides the core user interface functions for the GNOME desktop environment and is highly customizable.
GNOME Shell
Parts of the GNOME Shell:
- Top bar
- Activities overview
- System menu
- Dash
- Windows overview
- Workspace selector
- Message tray
Parts of the GNOME Shell:
The bar that runs along the top of the screen. It is displayed in the Activities overview and in workspaces.
Top bar
Parts of the GNOME Shell:
This is a special mode that helps a user organize windows and start applications.
Activities overview
Parts of the GNOME Shell:
The menu in the upper-right corner on the top bar provides control to adjust the brightness of the screen, and to switch on or off the network connections.
System menu
Parts of the GNOME Shell:
This is a configurable list of icons of the user’s favorite applications, applications which are currently running, and a grid button at the bottom of the dash which can be used to select arbitrary applications.
Dash
Parts of the GNOME Shell:
The dash is also sometimes called the ________.
dock
Parts of the GNOME Shell:
An area in the center of the Activities overview which displays thumbnails of all windows active in the current workspace. This allows windows to be more easily brought to the foreground on a cluttered workspace, or to be moved to another workspace.
Windows overview
Parts of the GNOME Shell:
An area to the right of the Activities overview which displays thumbnails of all active workspaces and allows workspaces to be selected and windows to be moved from one workspace to another.
Workspace selector
Parts of the GNOME Shell:
The message tray provides a way to review notifications sent by applications or system components to GNOME.
Message tray
(The message tray can be opened to review these notifications by clicking the clock on the top bar or by pressing Super+M. The message tray can be closed by clicking the clock on the top bar, or by pressing Esc or Super+M again.)
The other keys treated as modifier keys (like Super) by the on-screen keyboard are Shift, Ctrl, Alt, and Caps. The Esc and Menu keys are treated like normal keys and not modifier keys. (True or False)
T
The on-screen keyboard treats ______ as a modifier key that is often held down while pressing another key.
Super
(If you click it once, it will turn yellow indicating that the key is being held down. So, to enter Super+M in the on-screen keyboard, click Super, then click M.)
are separate desktop screens that have different application windows. These can be used to organize the working environment by grouping open application windows by task.
Workspaces
There are two simple methods for switching between workspaces:
- press Ctrl+Alt+UpArrow or Ctrl+Alt+DownArrow
- switch to the Activities overview and click the desired workspace.
Like Super, in Red Hat’s current virtual training and self-paced training environments, ______ key combinations are not usually passed to the virtual machine in the classroom environment by your web browser.
Ctrl+Alt
clicking Ctrl, Alt, and then either UpArrow or DownArrow allows you to _________ using the on-screen keyboard
switch workspaces
Press the _______ key combination to open the Enter a Command and enter gnome-terminal
Alt+F2
2 ways to start a terminal:
- click Activities overview and select Terminal from the dash
- Alt+F2
appears that shows the system time and the name of the logged-in user.
lock screen curtain
( To unlock the screen, press Enter or Space to raise the lock screen curtain, then enter that user’s password on the lock screen.)
To lock screen: (2 ways)
- click system menu»_space; click lock button
- Super+L (Windows+L)
(The screen also locks if the graphical session is idle for a few minutes.)
To log out and end the current graphical login session:
- click system menu»_space; click (User) → Log Out
Powering off or Rebooting the System:
To shut down the system: (2 ways)
- click system menu»_space; power button
- Ctrl+Alt+Del
( In the dialog box that displays, you can choose to Power Off or Restart the machine, or Cancel the operation. If you do not make a choice, the system automatically shuts down after 60 seconds.)
is a program that interprets commands typed in by the user.
GNU Bourne-Again Shell (bash)
Each string typed into the shell can have up to three parts:
- command
- options
- arguments
If you want to type more than one command on a single line, use the ___________ as a command separator.
semicolon (;)
example:
[user@host]$ command1;command2
A semicolon is a member of a class of characters called ___________ that have special meanings for bash.
metacharacters
_________ command displays the current date and time. It can also be used by the superuser to set the system clock.
date
What is the output of:
[user@host ~]$ date
A) Sat Jan 26 08:13:50 IST 2019
B) 08:13
C) 01/26/2019
A) Sat Jan 26 08:13:50 IST 2019
What is the output of:
[user@host ~]$ date +%R
A) Sat Jan 26 08:13:50 IST 2019
B) 08:13
C) 01/26/2019
B) 08:13
What is the output of:
[user@host ~]$ date +%x
A) Sat Jan 26 08:13:50 IST 2019
B) 08:13
C) 01/26/2019
C) 01/26/2019
_________ command changes a user’s own password.
passwd
Example: [user@host ~]$ passwd Changing password for user user. Current password: old_password New password: new_password Retype new password: new_password passwd: all authentication tokens updated successfully.
_________ command scans the beginning of a file’s contents and displays what type it is.
file
_________ command allows you to create single or multiple files, view the contents of files, concatenate the contents from multiple files, and redirect the contents of the file to a terminal or files.
cat
The example shows how to view the contents of the /etc/passwd file:
[user@host ~]$ cat /etc/passwd
display the contents of multiple files:
[user@host ~]$ cat file1 file2
The cat command displays the contents of a file as pages. (True or False)
F
The cat command does not display the contents of a file as pages.
_________ command displays one page of a file at a time and lets you scroll at your leisure.
less
_________ command allows you to page forward and backward through files that are longer than can fit on one terminal window.
less
Use the UpArrow key and the DownArrow key to scroll up and down. Press q to exit the command.
_________ and _________ commands display the beginning and end of a file, respectively.
head and tail
By default head and tail commands display 10 lines of the file, but they both have a ________ option that allows a different number of lines to be specified.
-n
example:
[user@host ~]$ tail -n 3 /etc/passwd
________ command counts lines, words, and characters in a file.
wc
(wc = word count)
example:
[user@host ~]$ wc /etc/passwd
wc command takes a ____, ____, or ____ option to display only the number of lines, words, or characters, respectively.
-l, -w, -c
examples:
[user@host ~]$ wc -l /etc/passwd ; wc -l /etc/group
or
[user@host ~]$ wc -c /etc/group /etc/hosts
_______ allows a user to quickly complete commands or file names after they have typed enough at the prompt to make it unique.
Tab completion
If the characters typed are not unique, pressing the Tab key ONCE displays all commands that begin with the characters already typed. (True or False)
F
If the characters typed are not unique, pressing the Tab key twice displays all commands that begin with the characters already typed.
_______ command is used by the superuser, root, to create additional users on the system. It has many options that can be used to control how that command behaves.
useradd
to make command readability easier, you can type a long command using more than one line you will use a ________ character, referred to as the escape character, to ignore the meaning of the character immediately following the backslash.
backslash ()
The shell acknowledges the request by displaying a continuation prompt, referred to as the secondary prompt, using the _________ character by default, on an empty new line.
greater-than (>)
The shell interprets a typed greater-than character as _________, which the user did not intend.
process redirection
_________ command displays a list of previously executed commands prefixed with a command number.
history
Example:
[user@host ~]$ history
_________ character (!) is a metacharacter that is used to expand previous commands without having to retype them.
exclamation point (!)
_________ command expands to the command matching the number specified.
!number
Example:
[user@host ~]$ !26
_________ command expands to the most recent command that begins with the string specified.
!string
Example:
[user@host ~]$ !ls
_________ keys can be used to navigate through previous commands in the shell’s history.
arrow
edits the previous command in the history list.
UpArrow
DownArrow
LeftArrow
RightArrow
UpArrow
edits the next command in the history list.
UpArrow
DownArrow
LeftArrow
RightArrow
DownArrow
move the cursor left and right in the current command from the history list, so that you can edit it before running it.
UpArrow
DownArrow
LeftArrow
RightArrow
LeftArrow
RightArrow
You can use either the _________ or _________ key combination to insert the last word of the previous command at the cursor’s current location.
Esc+.
Alt+.
(Repeated use of the key combination will replace that text with the last word of even earlier commands in the history. )
bash has a command-line editing feature. This allows the user to use text editor commands to move around within and modify the current command being typed. (True or False)
T
Useful Command-line Editing Shortcuts: (7)
Ctrl+A Ctrl+E Ctrl+U Ctrl+K Ctrl+LeftArrow Ctrl+RightArrow Ctrl+R
Jump to the beginning of the command line.
Ctrl+A Ctrl+E Ctrl+U Ctrl+K Ctrl+LeftArrow Ctrl+RightArrow Ctrl+R
Ctrl+A
Jump to the end of the command line.
Ctrl+A Ctrl+E Ctrl+U Ctrl+K Ctrl+LeftArrow Ctrl+RightArrow Ctrl+R
Ctrl+E
Clear from the cursor to the beginning of the command line.
Ctrl+A Ctrl+E Ctrl+U Ctrl+K Ctrl+LeftArrow Ctrl+RightArrow Ctrl+R
Ctrl+U
Clear from the cursor to the end of the command line.
Ctrl+A Ctrl+E Ctrl+U Ctrl+K Ctrl+LeftArrow Ctrl+RightArrow Ctrl+R
Ctrl+K
Jump to the beginning of the previous word on the command line.
Ctrl+A Ctrl+E Ctrl+U Ctrl+K Ctrl+LeftArrow Ctrl+RightArrow Ctrl+R
Ctrl+LeftArrow
Jump to the end of the next word on the command line.
Ctrl+A Ctrl+E Ctrl+U Ctrl+K Ctrl+LeftArrow Ctrl+RightArrow Ctrl+R
Ctrl+RightArrow
Search the history list of commands for a pattern.
Ctrl+A Ctrl+E Ctrl+U Ctrl+K Ctrl+LeftArrow Ctrl+RightArrow Ctrl+R
Ctrl+R
Which Bash shortcut or command jumps to the beginning of the previous word on the command line?
A) Pressing Ctrl+LeftArrow
B) Pressing Ctrl+K
C) Pressing Ctrl+A
D) !string
E) !number
A) Pressing Ctrl+LeftArrow`
Which Bash shortcut or command separates commands on the same line?
A) Pressing Tab
B) history
C) ;
D) !string
E) Pressing Esc+.
C) ;
Which Bash shortcut or command is used to clear characters from the cursor to the end of the command line?
A) Pressing Ctrl+LeftArrow
B) Pressing Ctrl+K
C) Pressing Ctrl+A
D) ;
E) Pressing Esc+.
B) Pressing Ctrl+K
Which Bash shortcut or command is used to re-execute a recent command by matching the command name?
A) Pressing Tab
B) !number
C) !string
D) history
E) Pressing Esc+.
C) !string
Which Bash shortcut or command is used to complete commands, file names, and options?
A) ;
B) !number
C) history
D) Pressing Tab
E) Pressing Esc+.
D) Pressing Tab
Which Bash shortcut or command re-executes a specific command in the history list?
A) Pressing Tab
B) !number
C) !string
D) history
E) Pressing Esc+.
B) !number
Which Bash shortcut or command jumps to the beginning of the command line?
A) !number
B) !string
C) Pressing Ctrl+LeftArrow
D) Pressing Ctrl+K
E) Pressing Ctrl+A
E) Pressing Ctrl+A
Which Bash shortcut or command displays the list of previous commands?
A) Pressing Tab
B) !string
C) !number
D) history
E) Pressing Esc+.
D) history
Which Bash shortcut or command copies the last argument of previous commands?
A) Pressing Ctrl+K
B) Pressing Ctrl+A
C) !number
D) Pressing Esc+.
D) Pressing Esc+.
is a command interpreter that prompts interactive users to specify Linux commands.
Bash shell
Many commands have a _______ option that displays a usage message or screen.
–help
Using _______ makes it easier to organize multiple application windows.
workspaces
The _______ button located at the upper-left corner of the top bar provides an overview mode that helps a user organize windows and start applications.
Activities
You can use __________ completion to complete file names when typing them as arguments to commands.
Tab