MODULE 5- Command line skills Flashcards

1
Q

Which program receives user-entered commands in a terminal and translates them into actions for the operating system?

A

The shell, which interprets commands typed at the terminal and executes them.

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

Which shell is the most commonly used one on Linux distributions and supports features like command history and inline editing?

A

The Bash shell (Bourne Again SHell).

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

Which shell feature allows a user to run an entire series of commands from a text file, including logic and functions?

A

Scripting, which allows commands and logic to be executed from a file.

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

Which shell feature allows creating nicknames for long or frequently-used commands?

A

Aliases, which act as shortcuts for longer commands.

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

Which shell feature lets users and the system store information such as settings or data used during command execution?

A

Variables, which can store and retrieve information in the shell environment.

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

Which term refers to a software program that performs an action when executed on the command line?

A

A command.

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

Which command, when run with no options or arguments, lists the files and directories in the current working directory?

A

ls

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

In the command syntax command [options] [arguments], which part is used to change how the command behaves?

A

Options

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

In the command syntax command [options] [arguments], which part provides extra information like filenames or usernames?

A

Arguments.

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

Which rule must always be followed when entering commands, filenames, or variables in a Linux terminal?

A

Linux is case-sensitive—inputs must be typed exactly as shown.

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

Which symbol in the CLI represents the user’s home directory ?

A

The ~ symbol.

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

How can you list the contents of both /etc/ppp and /etc/ssh in one command?

A

ls /etc/ppp /etc/ssh

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

Which option of the ls command displays a long listing format with file permissions, ownership, and size?

A

-l

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

Which option causes the ls command to reverse the order of the listing?

A

-r

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

What does the command ls -lr display?

A

A long listing of files in reverse alphabetical order.

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

What is the output of ls -lh /usr/bin/perl compared to ls -l /usr/bin/perl?

A

It shows the file size in human-readable format (e.g., 11K instead of 10376).

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

What is the long-form equivalent of the -h option in ls?

A

(- -human-readable

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

Which key can you press to cycle backward through previously executed commands?

A

Up Arrow (↑).

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

Which command displays the list of commands executed in the current terminal session?

A

history

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

Which keys allow editing of a recalled command by moving the cursor left or right?

A

Left Arrow (←) and Right Arrow (→).

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

What command would display the last 3 commands executed in a session?

A

history 3

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

Which symbol is used to re-execute a command by referencing its number in the history list?

A

! (exclamation mark).

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

Which command would Re-execute command number 3 from the history list?

A

!3

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

Which command would Re-execute the third command from the bottom of the history list?

A

!-3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Which command re-executes the most recently run command?
!!
16
Which command re-executes the most recent use of a specific command like ls?
!ls
17
How do you view the history list without re-executing anything?
history
18
Which type of variable exists only in the current shell session and disappears when the session ends?
Local variable
19
Which type of variable is commonly used for user tasks and is written in lowercase by convention?
Local variable
19
Which expression is used to assign a value to a variable in the shell?
variable=value
20
What happens if a local variable already exists and is assigned a new value?
Its value is modified.
21
Which command is used to display the value stored in a variable?
echo
22
How do you reference the value of a variable when using the echo command?
By placing a $ before the variable name (e.g., $variable1)
23
Which type of variable is available system-wide and persists across all Bash shells?
Environment variable (or global variable)
24
What type of variable is PATH, HOME, or HISTSIZE an example of?
Environment variable
25
Which environment variable controls how many previous commands are stored in the history list?
HISTSIZE
26
Which command would you use to modify an environment variable named HISTSIZE to store only 500 commands?
HISTSIZE=500
27
Which command outputs the full list of environment variables in the current shell?
env
28
What command structure would you use to filter the output of env to search for a specific variable?
env | grep variable_name
29
What is the result of running env | grep variable1 if variable1 is only a local variable?
No output
30
Which command is used to convert a local variable into an environment variable?
export variable
31
Which command both creates and exports a variable in a single step?
export variable2='Else'
32
Which command allows a variable to be modified by concatenating its value with another variable's value?
variable1=$variable1' '$variable2
33
Which command is used to remove an exported variable from the environment?
unset variable_name
34
Which environment variable defines the directories Bash searches for commands?
PATH
35
What character is used to separate directories in the PATH variable?
Colon (:)
36
What does the following command do? PATH=/usr/bin/custom:$PATH
It prepends /usr/bin/custom to the PATH, keeping existing directories.
37
Which command shows whether another command is built-in, external, or something else?
type
38
Which command shows the exact path of a command as found in the PATH variable?
which
38
If a command like echo exists both as a shell builtin and in /bin/, how can you see both versions?
type -a echo
39
Which option of the type command displays all locations for a command name?
-a
40
If the output of a command is /usr/bin/command, what kind of command is it?
External command
41
If a command doesn't work and you suspect it's overridden by a function or alias, which command helps check?
type
42
Which shell feature allows grouping multiple commands into a reusable block under a custom name?
Function
42
What command creates an alias named mycal for cal 2019?
alias mycal="cal 2019"
42
Which feature allows you to assign a short name to a longer command for faster access?
Alias
43
What command shows all aliases currently set in the shell session?
alias
43
If alias l='ls -CF' is set, what command is executed when you type l?
ls -CF (combo output and sort by file type)
44
What does the following command do? alias grep='grep --color=auto'
Enhances the grep command to always highlight matches with color
44
What command checks whether ll is an alias or something else?
type ll
45
What do the curly braces {} in a function definition indicate?
They enclose the beginning and end of the function body
45
What is the syntax used to define a Bash function called greet?
greet () { commands }
46
Which type of quotes prevent glob characters from being expanded into filenames?
Double quotes (")
47
Which characters are considered glob characters in Bash?
Asterisk (*), question mark (?), and square brackets ([ ])
48
What do we call the Shell behavior where wildcard characters match files or patterns
globbing
49
Which type of quotes prevent the shell from interpreting any special characters, including variables and globs?
Single quotes (')
50
How can you prevent the $ symbol from being treated as a variable indicator while still using double quotes?
Use a backslash ( \ ) before the dollar sign: \$
51
When inside single quotes, can the shell interpret metacharacters like *, ?, or $?
No, everything inside is treated literally
52
Which special characters are used to perform command substitution in the Bash shell?
Backquotes (`)
53
Which symbol is used to separate multiple commands so they run consecutively regardless of each other's success?
Semicolon (;)
53
Which symbol is used to run a second command only if the first command is successful?
Double ampersand (&&)
54
What is the behavior of the && operator between commands?
The second command runs only if the first command succeeds.
55
What happens if command1 fails in a command1 && command2 structure?
command2 does not run
56
Which symbol is used to run a second command only if the first command fails?
Double pipe (||)
56
What is the behavior of the || operator between commands?
The second command runs only if the first command fails.
56
How would you write a command that displays "Error!" only if cat file.txt fails?
cat file.txt || echo "Error!"
57
Which command displays the username of the current user?
Whoami
57
Which command shows name of kernel currently being used?
uname
58
Which command is used to show the network node hostname ?
uname -n
58
Which command is used to clear the screen?
clear
59
Which command is used to display the last five commands from your history?
history 5
60
For which type of commands does the type command display the location of the command?
External commands
61
Which character prevents the shell from interpreting all special characters?
(') single quote
61
Which character prevents the shell from interpreting glob character?
('') double quotes
62
Which character causes command substitution?
(`) backquotes
63
Which character prevents the shell from interpreting a single character?
(\) backslash
64
Which other method besides using a backquote is useful for command substitution?
$(command)
64
What do you do if you do not want the backquotes to be used to execute a command?
Place single quotes around them
64
Which characters create a logical "and" statement?
&&
65
Which characters characters create a logical "or" statement?
||