Module 7 Flashcards

1
Q

What is Git?

  • Another name for Gigabit
  • Version control software
  • Configuration management software
  • Open source malware
A
  • Version control software
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which numeric variable test expressions work? (Select two)

  • (($A == $B))
  • ((! $A -eq $D))
  • (($A != $C))
  • ((! $A = $D))
A
  • (($A == $B))

- (($A != $C))

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

What does export a variable mean?

  • Allow the variable to become accessible by child processes
  • Allow the variable to become accessible by parent process
  • Send the variable to a file
  • Send the variable to foreign countries
A
  • Allow the variable to become accessible by child processes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which command will display the following information?

The number of different shells being used on a Linux system

  • $ cat /etc/passwd | cut -d: -f7 | uniq | sort | wc -l
  • $ cat /etc/passwd | cut -d: -f7 | wc -l | sort | uniq
  • $ cat /etc/passwd | cut -d: -f7 | sort | wc -l | uniq
  • $ cat /etc/passwd | cut -d: -f7 | sort | uniq | wc -l
A
  • $ cat /etc/passwd | cut -d: -f7 | sort | uniq | wc -l
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

! /bin/bash

What will be displayed? Assume the script has the execution bit set.

$ cat myscript.sh

echo “$0 $@ $1 $2”
$ ./myscript.sh Hello World!

  • Nothing
  • Hello World!
  • ./myscript.sh Hello World!
  • ./myscript.sh Hello World! Hello World!
A
  • ./myscript.sh Hello World! Hello World!
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which outputs are a result of the following command? (Choose all that apply) Assume each original name started with a capitalized letter followed by lower-case letters.

$ tr [h-z][H-Z] < names

  • DONaLd DUcK
  • MIcKeY MOUSe
  • WaLT DiSNey
  • WiNNie THe POOH
A
  • DONaLd DUcK

- MIcKeY MOUSe

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

What will be displayed? Assume the script has the execution bit set.

$ cat myscript.sh

#! /bin/bash
function print_positional_params () {
echo "$3 $1 $2"
}
print_positional_params "$3" "$2" "$1"
#./myscript.sh one two three
  • one two three
  • one three two
  • two three two
  • three one two
A
  • one three two
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Find the match.

[ A = B ]
[ A -eq B ]
[ -d A ]
[ -f A ]

Strings A is equal to String B
A is numerically equal to B
A is a directory that exists
A is a file that exists

A

[ A = B ] Strings A is equal to String B

[ A -eq B ] A is numerically equal to B

[ -d A ] A is a directory that exists

[ -f A ] A is a file that exists

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

Which command will display the following information?

The number of users who use BASH shell

  • $ cat /etc/passwd | cut -d: -f7 | sort | grep bash
  • $ cat /etc/passwd | cut -d: -f7 | sort | wc -l
  • $ cat /etc/passwd | cut -d: -f7 | wc -l | grep bash
  • $ cat /etc/passwd | cut -d: -f7 | grep bash | wc -l
A
  • $ cat /etc/passwd | cut -d: -f7 | grep bash | wc -l
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you run a shell script? (Select three)

Assume the file has the execute bit set . PATH is not set to the current directory.

  • myscript.sh
  • ./myscript.sh
  • . ./myscript.sh
  • source ./myscript.sh
A
  • ./myscript.sh
  • . ./myscript.sh
  • source ./myscript.sh
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Before a user-defined variable can be used by processes that run in subshells, that variable must be __________.

  • imported
  • Falsevalidated by running the env command
  • exported
  • redirected to the BASH shell
A
  • exported
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which of the following will display the message welcome home if the cd /home/user1 command is successfully executed?

  • cd /home/user1 && echo “welcome home”
  • cat “welcome home” || cd /home/user1
  • cd /home/user1 || cat “welcome home”
  • echo “welcome home” && cd /home/user1
A
  • cd /home/user1 && echo “welcome home”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you indicate a comment line in a shell script?

  • There are no comment lines in a shell script.
  • Begin the line with #!.
  • Begin the line with !.
  • Begin the line with #.
A
  • Begin the line with #.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
Consider the following shell script:
echo -e “What is your favorite color?--> \c”
read REPLY
if [ $REPLY = “red” -o $REPLY = “blue” ]
then
echo “The answer is red or blue.”
else
echo “The answer is not red nor blue.”
fi

What would be displayed if a user executes this shell script and answers Blue when prompted?

  • The answer is red or blue.
  • The answer is not red nor blue.
  • The code would cause an error.
  • The answer is red or blue. The answer is not red nor blue.
A
  • The answer is not red nor blue.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

The sed and awk commands are filter commands commonly used to format data within a pipe. True or False?

True

False

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

Which of the following variables could access the value “/etc” within the sample shell script, if the sample shell script was executed using the bash sample /var /etc /bin command?

  • $0
  • $1
  • $2
  • $3
A
  • $2
17
Q

Both aliases and functions can be used to store commands that can be executed, but functions can also accept positional parameters. True or False?

True
False

A
  • True
18
Q

What would be the effect of using the alias command to make an alias for the date command named cat in honor of your favorite pet?

  • It cannot be done as there already is an environment variable cat associated with the cat command.
  • It cannot be done because there already is a command cat on the system.
  • When you use the cat command at the command prompt with the intention of viewing a text file, the date appears instead.
  • There is no effect until the alias is imported because it is a user-declared variable.
A
  • When you use the cat command at the command prompt with the intention of viewing a text file, the date appears instead.
19
Q

Which of the following lines can be used to perform command substitution within a shell script? (Choose all that apply.)

  • command
  • ${command}
  • ${!command}
  • $(command)
A
  • command

- $(command)

20
Q

Which of the following operators reverses the meaning of a test statement?

  • # !
  • -o
  • -a
  • !
A
  • !