GNUUnix Flashcards

1
Q
Which of the following commands can be used to create a USB storage media from a disk image?A.
gdisk
B.
dd
C.
cc
D.
fdisk
E.
mount
A

dd

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
In Bash, inserting 1>&2 after a command redirects?
A.
standard error to standard input.
B.
standard input to standard error.
C.
standard output to standard error.
D.
standard error to standard output.
E.
standard output to standard input.
A

standard output to standard error.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
What command will generate a list of user names from /etc/passwd along with their login shell?
A.
column -s : 1,7 /etc/passwd
B.
chop -c 1,7 /etc/passwd
C.
colrm 1,7 /etc/passwd
D.
cut -d: -f1,7 /etc/passwd
A

cut -d: -f1,7 /etc/passwd

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
In a nested directory structure, which find command line option would be used to restrict the
command to searching down a particular number of subdirectories?
A.
-dirmax
B.
-maxdepth
C.
-maxlevels
D.
-n
A

-maxdepth

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

Which of the following statements is correct regarding the command foo 1> bar?
A.
The stdout from the command foo is appended to the file bar.
B.
The stdout from the command foo overwrites the file bar.
C.
The command foo receives its stdin from the file bar.
D.
The command foo receives its stdin from the stdout of the command bar.
E.
The stderr from the command foo is saved to the file bar.

A

The stdout from the command foo overwrites the file bar.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
Which of the following commands kills the process with the PID 123 but allows the process to
"clean up" before exiting?
A.
kill -PIPE 123
B.
kill -KILL 123
C.
kill -STOP 123
D.
kill -TERM 123
A

kill -TERM 123

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

Which signal is missing from the following command that is commonly used to instruct a daemon
to reinitialize itself, including reading configuration files?
killall -s _______ daemon

A

HUP, SIGHUP, 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
What is the maximum niceness value that a regular user can assign to a process with the nice
command when executing a new process?
A.
9
B.
19
C.
49
D.
99
A

19

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
Immediately after deleting 3 lines of text in vi and moving the cursor to a different line, which single
character command will insert the deleted content below the current line?
A.
i (lowercase)
B.
P (uppercase)
C.
p (lowercase)
D.
U (uppercase)
E.
u (lowercase)
A

p (lowercase)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
A user accidentally created the subdirectory \dir in his home directory. Which of the following
commands will remove that directory?
A.
rmdir '~/\dir'
B.
rmdir "~/\dir"
C.
rmdir ~/'dir'
D.
rmdir ~/\dir
E.
rmdir ~/\\dir
A

rmdir ~/\dir

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
In compliance with the FHS, in which of the directories are man pages found?
A.
/usr/share/man
B.
/opt/man
C.
/usr/doc/
D.
/var/pkg/man
E.
/var/man
A

/usr/share/man

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
Which of the following commands will send output from the program myapp to both standard
output (stdout) and the file file1.log?
A.
cat < myapp | cat > file1.log
B.
myapp 0>&amp;1 | cat > file1.log
C.
myapp | cat > file1.log
D.
myapp | tee file1.log
E.
tee myapp file1.log
A

myapp | tee file1.log

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

What is the purpose of the Bash built-in export command?
A.
It allows disks to be mounted remotely.
B.
It runs a command as a process in a subshell.
C.
It makes the command history available to subshells.
D.
It sets up environment variables for applications.
E.
It shares NFS partitions for use by other systems on the network.

A

It sets up environment variables for applications.

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

What is the output of the following command?

echo “Hello World” | tr -d aieou

A.
Hello World
B.
eoo
C.
Hll Wrld
D.
eoo Hll Wrld
A

Hll Wrld

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

Which of the following characters can be combined with a separator string in order to read from
the current input source until the separator string, which is on a separate line and without any
trailing spaces, is reached?
A.
«
B.

A

<

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

Which of the following commands will NOT update the modify timestamp on the file /tmp/myfile.txt?

A.
file /tmp/myfile.txt
B.
echo "Hello" >/tmp/myfile.txt
C.
sed -ie "s/1/2/" /tmp/myfile.txt
D.
echo -n "Hello" >>/tmp/myfile.txt
E.
touch /tmp/myfile.txt
A

file /tmp/myfile.txt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q
What is the default nice level when a process is started using the nice command?
A.
-10
B.
10
C.
20
D.
0
A

10

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

What is the default action of the split command on an input file?
A.
It will break the file into new files of 1,024 byte pieces each.
B.
It will break the file into new files of 1,000 line pieces each.
C.
It will break the file into new files of 1,024 kilobyte pieces each.
D.
It will break the file into new files that are no more than 5% of the size of the original file.

A

It will break the file into new files of 1,000 line pieces each.

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

What is the difference between the i and a commands of the vi editor?
A.
i (interactive) requires the user to explicitly switch between vi modes whereas a (automatic)
switches modes automatically.
B.
i (insert) inserts text before the current cursor position whereas a (append) inserts text after the
cursor.
C.
i (independent rows) starts every new line at the first character whereas a (aligned rows) keeps
the indentation of the previous line.

A

i (insert) inserts text before the current cursor position whereas a (append) inserts text after the
cursor.

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

Which command displays a list of all background tasks running in the current shell? (Specify
ONLY the command without any path or parameters.)

A

jobs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q
Which of the following commands moves and resumes in the background the last stopped shell job?
A.
run
B.
bg
C.
fg
D.
back
A

bg

22
Q

What is the effect of the egrep command when the -v option is used?
A.
It enables color to highlight matching parts.
B.
It only outputs non-matching lines.
C.
It shows the command’s version information.
D.
It changes the output order showing the last matching line first.

A

It only outputs non-matching lines.

23
Q

What does the ? symbol within regular expressions represent?
A.
Match the preceding qualifier one or more times.
B.
Match the preceding qualifier zero or more times.
C.
Match the preceding qualifier zero or one times.
D.
Match a literal ? character.

A

Match the preceding qualifier zero or one times.

24
Q

In the vi editor, how can commands such as moving the cursor or copying lines into the buffer be issued multiple times or applied to multiple rows?
A.
By using the command :repeat followed by the number and the command.
B.
By specifying the number right in front of a command such as 4l or 2yj.
C.
By selecting all affected lines using the shift and cursor keys before applying the command.

A

By specifying the number right in front of a command such as 4l or 2yj.

25
Q
Which of the following files, located in the user home directory, is used to store the Bash history?
A.
.bash_history
B.
.bash_histfile
C.
.history
D.
.bashrc_history
E.
.history_bash
A

.bash_history

26
Q

Which Bash environment variable defines in which file the user history is stored when exiting a
Bash process? (Specify ONLY the variable name.)

A

HISTFILE

27
Q
Which of the following commands displays the contents of a gzip compressed tar archive?
A.
gzip archive.tgz | tar xvf -
B.
tar ztf archive.tgz
C.
gzip -d archive.tgz | tar tvf -
D.
tar cf archive.tgz
A

tar ztf archive.tgz

28
Q
Which grep command will print only the lines that do not end with a / in the file foo?
A.
grep '/$' foo
B.
grep '/#' foo
C.
grep -v '/$' foo
D.
grep -v '/#' foo
A

grep -v ‘/$’ foo

29
Q
Which of the following commands is used to change options and positional parameters for a running Bash?
A.
history
B.
set
C.
bashconf
D.
setsh
E.
envsetup
A

set

30
Q
Which of the following commands replaces each occurrence of 'bob' in the file letter with 'Bob' and writes the result to the file newletter?
A.
sed '/bob/Bob' letter > newletter
B.
sed s/bob/Bob/ letter < newletter
C.
sed 's/bob/Bob' letter > newletter
D.
sed 's/bob/Bob/g' letter > newletter
E.
sed 's/bob, Bob/' letter > newletter
A

sed ‘s/bob/Bob/g’ letter > newletter

31
Q

From a Bash shell, which of the following commands directly executes the instruction from the file
/usr/local/bin/runme.sh without starting a subshell? (Please select TWO answers.)

A.
source /usr/local/bin/runme.sh
B.
. /usr/local/bin/runme.sh
C.
/bin/bash /usr/local/bin/runme.sh
D.
/usr/local/bin/runme.sh
E.
run /usr/local/bin/runme.sh
A

source /usr/local/bin/runme.sh

. /usr/local/bin/runme.sh

32
Q

Regarding the command:
nice -5 /usr/bin/prog
which of the following statements is correct?
A.
/usr/bin/prog is executed with a nice level of -5.
B.
/usr/bin/prog is executed with a nice level of 5.
C.
/usr/bin/prog is executed with a priority of -5.
D.
/usr/bin/prog is executed with a priority of 5.

A

/usr/bin/prog is executed with a nice level of 5.

33
Q
Which shell command is used to continue background execution of a suspended command?
A.
&amp;
B.
bg
C.
cont
D.
exec
E.
\:&amp;
A

bg

34
Q
Which of the following shell redirections will write standard output and standard error output to a file named filename?
A.
2>&amp;1 >filename
B.
>filename 2>&amp;1
C.
1>&amp;2>filename
D.
>>filename
E.
1&amp;2>filename
A

> filename 2>&1

35
Q
In the vi editor, which of the following commands will copy the current line into the vi buffer?
A,
c
B.
cc
C.
1c
D.
yy
E.
1y
A

yy

36
Q
Which of the following sequences in the vi editor saves the opened document and exits the editor?
(Choose TWO correct answers.)
A.
esc ZZ
B.
ctrl :w!
C.
esc zz
D.
esc :wq!
E.
ctrl XX
A

esc ZZ

esc :wq!

37
Q
When starting a program with the nice command without any additional parameters, which nice level is set for the resulting process?
A.
-10
B.
0
C.
10
D.
20
A

10

38
Q
Which of the following commands will reduce all consecutive spaces down to a single space?
A.
tr '\s' ' ' < a.txt > b.txt
B.
tr -c ' ' < a.txt > b.txt
C.
tr -d ' ' < a.txt > b.txt
D.
tr -r ' ' '\n' < a.txt > b.txt
E.
tr -s ' ' < a.txt > b.txt
A

tr -s ‘ ‘ < a.txt > b.txt

39
Q
Which character, added to the end of a command, runs that command in the background as a child process of the current shell?
A.
!
B.
\+
C.
&amp;
D.
%
E.
#
A

&

40
Q
Which of the following commands will print the last 10 lines of a text file to the standard output?
A.
cat -n 10 filename
B.
dump -n 10 filename
C.
head -n 10 filename
D.
tail -n 10 filename
A

tail -n 10 filename

41
Q
Which of the following commands prints a list of usernames (first column) and their primary group
(fourth column) from the /etc/passwd file?
A.
fmt -f 1,4 /etc/passwd
B.
split -c 1,4 /etc/passwd
C.
cut -d : -f 1,4 /etc/passwd
D.
paste -f 1,4 /etc/passwd
A

cut -d : -f 1,4 /etc/passwd

42
Q
Which of the following signals is sent to a process when the key combination CTRL+C is pressed on the keyboard?
A.
SIGTERM
B.
SIGINT
C.
SIGSTOP
D.
SIGKILL
A

SIGINT

43
Q

What happens after issuing the command vi without any additional parameters?
A.
vi starts and loads the last file used and moves the cursor to the position where vi was when it last
exited.
B.
vi starts and requires the user to explicitly either create a new or load an existing file.
C.
vi exits with an error message as it cannot be invoked without a file name to operate on.
D.
vi starts in command mode and opens a new empty file.
E.
vi starts and opens a new file which is filled with the content of the vi buffer if the buffer contains
text.

A

vi starts in command mode and opens a new empty file.

44
Q
Which of the following command sets the Bash variable named TEST with the content FOO?
A.
set TEST="FOO"
B.
TEST = "FOO"
C.
var TEST="FOO"
D.
TEST="FOO"
A

TEST=”FOO”

45
Q
Which variable defines the directories in which a Bash shell searches for executable commands?
A.
BASHEXEC
B.
BASHRC
C.
PATH
D.
EXECPATH
E.
PATHRC
A

PATH

46
Q
Which of the following commands determines the type of a file by using a definition database file
which contains information about all common file types?
A.
magic
B.
type
C.
file
D.
pmagic
E.
hash
A

file

47
Q

Which command is used in a Linux environment to create a new directory? (Specify ONLY the command without any path or parameters.)

A

mkdir, /usr/bin/mkdir

48
Q
Which of the following commands prints all files and directories within the /tmp directory or its
subdirectories which are also owned by the user root? (Choose TWO correct answers.)
A.
find /tmp -uid root -print
B.
find -path /tmp -uid root
C.
find /tmp -user root -print
D.
find /tmp -user root
E.
find -path /tmp -user root –print
A

find /tmp -user root -print

find /tmp -user root

49
Q

When running the command
sed -e “s/a/b/” /tmp/file >/tmp/file while /tmp/file contains data, why is /tmp/file empty afterwards?
A.
The file order is incorrect. The destination file must be mentioned before the command to ensure
redirection.
B.
The command sed did not match anything in that file therefore the output is empty.
C.
When the shell establishes the redirection it overwrites the target file before the redirected
command starts and opens it for reading.
D.
Redirection for shell commands do not work using the > character. It only works using the |
character instead.

A

When the shell establishes the redirection it overwrites the target file before the redirected
command starts and opens it for reading.

50
Q
When given the following command line.
echo "foo bar" | tee bar | cat
Which of the following output is created?
A.
cat
B.
foo bar
C.
tee bar
D.
bar
E.
foo
A

foo bar

51
Q
Which of the following commands can be used to determine how long the system has been
running? (Choose TWO correct answers.)
A.
uptime
B.
up
C.
top
D.
uname -u
E.
time –up
A

uptime

top

52
Q
Which of the following are valid stream redirection operators within Bash? (Choose THREE correct answers.)
A.
<
B.
<<<
C.
>
D.
>>>
E.
%>
A
A.
<
B.
<<<
C.
>