2.1 Command Line Basics - Part 1 Flashcards

1
Q

What is the name of the command line interface in Linux systems?

A

Bash

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is Bash?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Name two different “shell” names present on Linux operating systems

A

Bourne-again shell (Bash) is most common

Others shells include:

C shell (csh or tcsh, the enhanced csh)
Korn shell (ksh)
Z shell (zsh)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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

A

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:~$ _

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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

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:~# _

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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

A

B.) is correct.

psmith is the name of the user that runs the shell.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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. # _

A

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:# _

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

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

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

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

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

The shell supports TWO command types, what are they?

A
  1. 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)
  2. External - commands that reside inside files. These are usually binary programs or scripts. Users can create their own external commands.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the $PATH variable used for within the shell?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does “Quoting” allow a user to do in the bash shell?

A

Quoting allows the user to capture specific data or strings of information using:

Double quotes (“ “)
Single quotes (‘ ‘)

or

Escape characters (\)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

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

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”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

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.

A

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.

17
Q

Which of the following statements are true regarding Single Quotes (‘ ‘) that are typed in the bash shell?

a. Single quotes tell the shell to take the text between the two quote marks as regular characters except “$”, “", “ ‘ “

b. Single quotes are treated as plain string items and executed as typed

c. Single quotes are only used in bash scripts not executed as part of commands

d. Single 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

D.) is correct.

Single quotes revoked any special meaning for shell characters like “$”, “", “ ‘ “ and preserve the literal string of all characters within them.

ex:

echo I am $USER
I am tom
echo ‘I am $USER’
I am $USER

*The single quotes did not preserve the “$” character in $USER, which is why bash printed the literal string and did not call the variable $USER.

18
Q

Which of the following statements are true regarding the “Escape Character” (\) when it is typed into the bash shell?

a. Escape characters are used to reverse a directory listing hierarchy in the Linux file system

b. Escape characters are used to recursively delete scripts that have already been printed to bash.

c. Escape characters are used remove special meanings of characters from bash.

d. Escape characters allow ‘linkages’ between script programs in bash.

A

C.) is correct.

If the escape character (aka the backslash “") is preceded to a special character like “$”, a single quote, a single double quote, etc., then it will negate the special meaning

ex:

echo $USER
$USER

In the case above, the value assigned to the variable $USER was not printed to screen because of the presence of the ‘Escape Character’ (“") directly preceding the “$”.

The escape character told bash to ignore $ as a variable call command.

19
Q

What does the ‘echo’ command do in bash?

A

The echo command outputs text to the terminal line

20
Q

what does the ‘touch’ command do in bash?

A

The touch command creates an empty file or can be used to update an existing file’s modification date.

21
Q

what does the command ‘type’ do in bash?

A

The ‘type’ command shows what type a specific command is (either Internal or External).

ex:

type echo
echo is a shell builtin
type man
man is /usr/bin/man