2.1 Command Line Basics - Part 1 Flashcards
What is the name of the command line interface in Linux systems?
Bash
What is Bash?
Bash is the command line interface in Linux that enables text based communications between the operating system and the user.
Bash is also a programming language
Name two different “shell” names present on Linux operating systems
Bourne-again shell (Bash) is most common
Others shells include:
C shell (csh or tcsh, the enhanced csh)
Korn shell (ksh)
Z shell (zsh)
Reference the follow default prompt from a bash shell:
cloud_user@54.134.76.3:$ _
What does the “$” indicate:
a. It indicates the current user has root privileges
b. It indicates the current user has regular privleges
c. It indicates an system error and that the shell needs to reboot
d. It indicates the shell is still loading and to standby
B.) is correct.
”$” indicates the current user has regular privleges.
Some distributions like Ubuntu or Debian GNU might add a “~” prior to the “$”
ex: cloud_user@54.134.76.3:~$ _
Reference the follow default prompt from a bash shell:
cloud_user@54.134.76.3:# _
What does the “#” indicate:
a. It indicates the current user has root privileges
b. It indicates the current user has regular privleges
c. It indicates a system error and that the shell needs to reboot
d. It indicates the shell is still loading and for the user to standby
A.) is correct.
- # indicates the current user has root privileges.
Some distributions like Ubuntu or Debian GNU might add a “~” prior to the “$”
ex: cloud_user@54.134.76.3:~# _
Reference the following default prompt from a bash shell:
psmith@54.134.76.3:$ _
Which portion is the username?
a. 54.134.76.3
b. psmith
c. $ _
d. the username is not listed
B.) is correct.
psmith is the name of the user that runs the shell.
Reference the following default prompt from a bash shell:
pandabear435@2.19.546.2:$ _
Which portion is the hostname?
a. the hostname is not listed
b. $ _
c. 2.19.546.2
d. pandabear435
C.) is correct.
the hostname is the name of the host that the current shell is running on.
The command hostname can show you or allow you to set the system’s hostname
Reference the following default prompt from a bash shell:
blade83726435@12.654.21.8:# _
Which portion of the prompt above shows the “shell type”
a. the shell type is not listed
b. $ _
c. blade is the shell type
d. # _
D.) is correct.
The shell type indicates whether bash is being run by a ‘root’ (#) or ‘regular’ ($) user
This shell is being run by a root user.
blade83726435@12.654.21.8:# _
Reference the following string of character that has been typed into the bash shell:
ls -l /home
Which portion of the string is the command?
a. /home
b. ls
c. -l
d. no command is listed
B.) ls is correct.
ls is the ‘list’ command in bash. Commands are always listed first, before any options, parameters, or arguments.
Some commands do not require any options, parameters, or arguments
Reference the following string of character that has been typed into the bash shell:
ls -l /home
Which portion of the string is the option?
a. no option is listed
b. /home
c. ls
d. -l
D.) -l is correct.
-l is the ‘format long’ option in bash.
Options are always listed after the commands that they modify but before arguments
Reference the following string of character that has been typed into the bash shell:
ls -l /home
Which portion of the string is the argument?
a. -l
b. no argument is listed
c. /home
d. ls
C.) is correct.
/home is the path that the command ls with option -l is going to be executed on
Arguments can be files or directories and are listed after the command and any options associated with that command.
The shell supports TWO command types, what are they?
- Internal - commands that are part of the shell itself and are not separate programs. Their main purpose is executing tasks inside the shell. (ex: cd, set, export)
- External - commands that reside inside files. These are usually binary programs or scripts. Users can create their own external commands.
What is the $PATH variable used for within the shell?
The PATH variable is used by the shell to search for executable files that match the command AND programs installed via the distribution package manager.
What does “Quoting” allow a user to do in the bash shell?
Quoting allows the user to capture specific data or strings of information using:
Double quotes (“ “)
Single quotes (‘ ‘)
or
Escape characters (\)
Which of the following statements are true regarding Double Quotes (“ “) that are typed in the bash shell?
a. Double quotes tell the shell to take the text between the two quote marks as regular characters except “$”, “", “ ‘ “
b. Double quotes are treated as plain string items and executed as typed
c. Double quotes are only used in bash scripts not executed as part of commands
d. Double quotes tell the shell to take the text between the two quote marks and to print the literal string as typed. They revoke any special meaning from each character.
A.) is correct.
Because “$”, “", “ ‘ “ are all preserved as special characters within double quotes, this means that variables, command substitution and arithmetic functions can still be used.
ex:
echo I am $USER
I am tom
echo “I am $USER”
I am tom
*The double quotes preserve the “$” character in $USER, which is a special character used to call variables, which is why when $USER variable was called, bash printed “tom” and not “$USER”