Week 7 Comprehension Flashcards

1
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
2
Q

Find the match.

stderr()
stdout()
stdin()
|

0
1
Pipe
2

A

stderr() =2
stdout() =1
stdin() =0
| = Pipe

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

Which numeric variable test expressions work? (Select two)

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

A

A. (($A == $B))

C. (($A != $C))

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

! /bin/bash

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

$ cat myscript.sh

echo “$0 $@ $1 $2”

  • 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
5
Q

Which commands will work? (Select two)

$ ls > file1
$ file1 > file2
$ wc < file1
$ wc | file1

A

$ ls > file1

$ wc < file1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
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
7
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
8
Q

Suppose file1 exists but dir1 does not. Which command will write stdout and stderr to the same file? (Select two)

$ cat file1 dir1 2>file
$ cat file1 dir1 >file 2>&1
$ cat file1 dir1 2>&1 >file
$ cat file1 dir1 &>file

A

$ cat file1 dir1 >file 2>&1

$ cat file1 dir1 &>file

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

Which commands will work? (Select two)

$ ls > file1
$ file1 > file2
$ wc < file1
$ wc | file1

A

$ ls > file1

$ wc < file1

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

! /bin/bash

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

$ cat myscript.sh

function print_positional_params () {

echo “$3 $1 $2”

}

print_positional_params “$3” “$2” “$1”

  • 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