You are on page 1of 12

1 Command cd allows a user to change their current directory.

Which of the following statements


are true?
A,c
a. Command cd /home; cd mark changes the user's current directory to /home/mark, provided
/home/mark exists and the user has permissions to cd to it.
b. Command cd mark will change the user's current directory to /home/mark irrespectively of the
user's current directory.
c. Command cd /home/mark changes the user's current directory to /home/mark, provided
/home/mark exists and the user has permissions to cd to it.
d. Command cd /home/mark/bin/.. changes the user's current directory to /home/mark, provided
/home/mark/bin exists and the user has permissions to cd to it.

2 Assuming that you have the right to change permissions for existing file food.txt, after which of
the following commands you can be sure that its permissions are:- for the owner: at least readable
and executable- for the group: at least readable- for the others: at least readable

a,b,c
a. chmod u+rx,g+r,o+r food.txt
b. chmod 544 food.txt
c. chmod 755 food.txt
d. chmod u+r,g+r,o+r food.txt

3. Assuming file USP.txt exists and you can read it, the output of which of the following commands
contains the string USP.txt?
B,c,d
a. wc < USP.txt
b. wc USP.txt
c. wc -lwc USP.txt
d. wc USP.txt | cat

4 When you request the execution of a command on the command line by its filename, where does
the system certainly look for it?
C (b)
a. In extreme cases, searching the whole hard disk might be deemed necessary. Fortunately for
performance, this does not occur very often.
b. In system directories such as /bin, /usr/bin and /usr/local/bin.
c. In the list of directories specified in the environment variable PATH.
d. In your current directory.

5 Assuming shell variable LANGUAGE is currently assigned with value C, which of the following
commands assign it with value C++?
A,c,d
a. LANGUAGE='C++'
b. LANGUAGE='$LANGUAGE'++
c. LANGUAGE=`echo C++`
d. LANGUAGE=${LANGUAGE}++

6 Command ls is used to list directory contents. Which of the following statements are true,
provided directories exist and all relevant permissions apply?
A,d (a c d)
a. Command ls * lists all filenames in the current directory.
b. Command ls dir/* changes the current directory to dir and lists all filenames in it.
c. Command ls dir/* lists all filenames in directory dir, each preceded by string dir/.
d. Command ls `pwd`/* lists all filenames in the current directory as absolute pathnames.

7 Which of the following are correct statements about the i-nodes?


B,c,d
a. The filename of a file is stored in its i-node.
b. The i-node of a file contains the addresses of blocks containing the file's content.
c. The same i-node can have multiple names (links) in the file system..
d. Important information about a file or directory is contained in its i-node. The actual content of the
file or directory is stored elsewhere.

8 Command ls -i shows all i-node numbers and corresponding filenames in the current directory.
Which of the following statements are true?
B
a. The same filename can appear twice.
b. The same i-node number can appear multiple times.
c. The i-node numbers must all be contiguous (such as N, N+1, N+2 etc, with N an arbitrary
integer).

9 Assuming that a file system uses:- file blocks of 1024 B each;- block addresses of 4 B each;- i-
nodes with 12 direct links, 1 singly-indirect link, 1 doubly-indirect link, 1 triply-indirect link.What
links of an i-node are used for a file which is only 14 KB in size?
A
a. The 12 direct links and the singly-indirect link.
b. 2 direct links.
c. 14 direct links.
d. The 12 direct links, the singly-indirect link and the doubly-indirect link.

10 Assuming that a file system uses:- file blocks of 1024 B each;- block addresses of 4 B each;- i-
nodes with 12 direct links, 1 singly-indirect link, 1 doubly-indirect link, 1 triply-indirect link.Which
of the following statements are true?
Ace
a. The maximum size allowed by the singly-indirect link alone is 256 * 1024 = 256 KB.
b. The maximum size allowed by the singly-indirect link alone is 1024 * 4 KB = 4MB.
c. The maximum size allowed by 12 direct links alone is 12 * 1024 = 12 KB.
d. The maximum size allowed by the singly-indirect link alone is 256 * 1024 + 12 * 1024 = 268
KB.
e. The maximum size allowed by the doubly-indirect link alone is 256 * 256 * 1024 = 64 MB.

11 Assuming that filename cat does not exist in the current directory and that you have permissions
to create it, how many links exist to the i-node of filename leopard after the following commands?
touch cat ...> 1
ln cat tiger ...>2
ln tiger lion ...>3
ln lion leopard ...>4
C
a. 3
b. 1
c. 4
d. 2

12 Assuming that file food.txt has 32 lines and cannot be read by you, what do you expect to see on
your screen when command cat < food.txt | head -12 is executed?
A
a. The error message: "bash: food.txt: Permission denied".
b. 12.
c. Nothing, because of the piping with the head command.
d. The first twelve lines of the file.

13 Assuming file food.txt exists and you have all sorts of permissions, upon execution of command
head -6 < food.txt >> essentials.txt
A,c
a. If file essentials.txt did not exist, it is created and the first 6 lines of food.txt are stored into it.
b. If file essentials.txt existed, its content is deleted before execution of command head.
c. The first 6 lines of food.txt are appended at the end of file essentials.txt, if it existed.
d. If file essentials.txt did not exist, the first 6 lines of food.txt are displayed on the screen.

14 Commandecho $(($((5 - 10 + 2)) * 100 / 2))outputs:


C
a. -500
b. 150
c. -150
d. $(($((5 - 10 + 2)) * 100 / 2))

15 Given the alphabet {a, b, c, d, 1, 2, 3}, the following are languages over it:
(a c)
a. This set of strings (comma is the separator): {a, ab, abb, abba}.
b. This set of strings (comma is the separator): {a, az, za, z}.
c. This set of strings (comma is the separator): {a, b, 1}.
d. The empty set.

16 Choose which of the following strings match regular expression a*ccc*


a,b,c
a. cc
b. aaabbbccc
c. accc
d. aaabbb

17 Choose which of the following strings match regular expression(1 U 22)*2*


A,b,c,d,e
a. 22112222112211
b. 11112
c. The empty string.
d. 12121
e. 1121111222
18 Choose which of the following is the language generated by the regular expression (a U b)1
C
a. {ab1}
b. {a, b, 1}
c. {a1, b1}

19 If file test.txt in the current directory is readable by you and has the following content:
abd
d
aaaaabbbdddddd
aaaddddddddddd
aaaaaaaaaaaaaab
cccaaaacd
command egrep '[ab]+d' test.txt outputs the following lines only:
C(b
a. Lines:
d
abd
aaaaabbbdddddd
aaaddddddddddd
b. Lines:
abd
c. Lines:
abd
aaaaabbbdddddd
aaaddddddddddd

20 Which of the following statements about the grep command are true?
B,c
a. Command grep with option -F interprets regular expressions.
b. Command grep with option -l prints names of argument files where matches have occurred.
c. Command: grep abc food.txt prints all the lines of food.txt containing string abc at least once.
d. Command: grep -c abc food.txt will give an error message as not enough files have been
specified.
==============================
1 Which of the following are examples of absolute pathnames?
A,b,e
a. /usr/local/bin
b. /home/massimo/.login
c. ./myscript
d. ..
e. /

2 Assuming you have the right to change permissions for existing file food.txt, after which of the
following commands you can be sure that its permissions are:
- for the owner: readable, writable, executable
- for the group: readable, non writable, non executable
- for the others: readable, non writable, executable
a,b
a. chmod 745 food.txt
b. chmod u+rwx,g+r,g-wx,o+rx,o-w food.txt
c. chmod u+rwx,g+r,o+r food.txt
d. chmod 640 food.txt

3 Assuming file food.txt exists and you can read it, the output of which of the following commands
contains the string food.txt?
B,c
a. wc < food.txt
b. wc -c food.txt
c. wc food.txt
d. cat < food.txt | wc
e. cat food.txt | wc

4 When you request the execution of a command on the command line by its filename, where does
the system certainly look for it?
C,d
a. In extreme cases, searching the whole hard disk might be deemed necessary. Fortunately for
performance, this does not occur very often.
b. In your current directory.
c. In the list of directories specified in the environment variable PATH.
d. In system directories such as /bin, /usr/bin and /usr/local/bin.

5. Assuming shell variable MY_VAR is currently assigned with value BBA, which of the following
commands assign it with value ABBA?
A,b,c
a. MY_VAR=A`echo $MY_VAR`
b. MY_VAR=ABBA
c. MY_VAR=`echo ABBA`
d. MY_VAR=A + $MY_VAR

6. Given the command line


MY_NAME=`whoami`
which of the following answers describes the way it is executed?
A,
a. The system executes command whoami assigning its standard output as the value of shell
variable MY_NAME. The command?s standard output does not appear on the screen.
b. The system assigns string ?whoami? to shell variable MY_NAME.
c. The system executes command whoami assigning its standard output as the value of shell
variable MY_NAME. The command?s standard output also regularly appears on the screen.
d. The system displays string ?whoami? on the screen.

7 Which of the following are correct statements about the i-nodes?


A,b,d
a. Important information about a file or directory is contained in its i-node. The content of the file or
directory is stored elsewhere.
b. The i-nodes of a partition are stored in a special list (sometimes called an array).
c. The content of a file or directory is stored in an i-node.
d. The i-node of a file contains the addresses of blocks containing the file?s content.

8. Which of the following are correct statements about the i-nodes?


A,
a. A same i-node can be referred to by two or more filenames.
b. The filename of a file is stored in its i-node.
c. To survive across user sessions, i-nodes are stored in a computer?s Read-Only Memory (ROM).
d. The i-node of a file contains the maximum size the file can expand to.
Type a quote from the document or the summary of an interesting point. You can position the text]
box anywhere in the document. Use the Text Box Tools tab to change the formatting of the pull
[.quote text box
9 Assuming that a file system uses:
- file blocks of 1 KB each;
- i-nodes with 12 direct links, 1 singly-indirect link, 1 doubly-indirect link, 1 triply-indirect link.
What links of an i-node are used for a file of 24 KB size?
B,
a. Only 12 direct links.
b. 12 direct links and 1 singly-indirect link.
c. 24 direct links.
d. Only 1 singly-indirect link.

10 Assuming that a file system uses:


- N.B.! file blocks of 2048 B (byte) each;
- block addresses of 4 B.
What is the maximum size of a file that can be obtained through the singly-indirect link?
A
a. 1 MB
b. 2048 MB
c. 4 MB
d. 4 GB

11 How many links exist to filename g700 after the following commands?
> g700
ln g700 g800
ln g800 g900
rm g800
Assume that you have all the necessary permissions and file g700 does not previously exist.
D (c)
a. 0
b. 1
c. 3
d. 2

12 Assuming file food.txt has 32 lines and cannot be read by you, what do you expect to see on
your screen when command
cat < food.txt | head -12
is executed?
C
a. Nothing, because of the piping with the head command.
b. 12.
c. The error message: "bash: food.txt: Permission denied".
d. The first twelve lines of the file.

13 Assuming file food.txt exists and you have all sorts of permissions, upon execution of command
head -6 < food.txt >> essentials.txt
b,d
a. If file essentials.txt existed, its content is deleted before execution of command head.
b. The first 6 lines of food.txt are appended at the end of file essentials.txt, if it existed.
c. If file essentials.txt did not exist, the first 6 lines of food.txt are displayed on the screen.
d. If file essentials.txt did not exist, it is created and the first 6 lines of food.txt are stored into it.

14 Command
echo $(($((5 + 5 - 2)) * 100 - 50))
outputs:
D
a. 400
b. 8 * 100 - 50
c. (5 + 5 - 2) * 100 - 50
d. 750

15 Given the alphabet {a, b, c, d, 1, 2, 3}, the following are languages over it:
A
a. This set of strings (comma is the separator): {a, b, c, d}.
b. This set of strings (comma is the separator): {a, aA, aaA}.
c. This set of strings (comma is the separator): {a, bb, ccc}.
d. This set of strings (comma is the separator): {a1, 1a, aa1, 1aa}.
e. The empty set.

16 hoose which of the following strings match regular expression


a*b*ccc*
A,b,c
a. cc
b. bbccc
c. aaabbbccc
d. aaabbb

17 Choose which of the following strings match regular expression


(11)* U (22)*
B,d
a. 1122
b. 22
c. 222
d. 11111111
18 Choose which of the following is the language generated by the regular expression
ab(c U d U e)
D
a. {ab, cde}
b. {ab, c, d, e}
c. {abcde}
d. {abc, abd, abe}

19 Which of the following statements about the grep command are true?
D c?
a. Command: grep ?f abc food.txt is generally slower than command: grep abc food.txt.
b. Command grep with option ?f interprets regular expressions.
c. Command grep with option ?l prints names of argument files where matches have occurred.
d. Command: grep abc food.txt prints all the lines of food.txt containing string abc at least once.

20 Which of the following statements about bash expansions are true?


B, a?, d?
a. Parameter and variable expansion takes place before pathname expansion.
b. Command substitutions and arithmetic expansions take place in left-to-right order.
c. Command substitutions cannot be nested.
d. Command: echo `echo $((3 * 4))` outputs: 12.
============================
1 Which of the following are examples of relative pathnames?
cd
a. /etc/password
b. /
c. CHARLES
d. ../../marcelus/script.sh

2 Assuming you have the right to change permissions for existing file food.txt, after which of the
following commands you can be sure that its permissions are:
- for the owner: readable, writable, non executable
- for the group: readable, non writable, non executable
- for the others: non readable, non writable, non executable
b
a. chmod u+rw g+r food.txt
b. chmod 640 food.txt
c. chmod food.txt 640
d. chmod 755 food.txt

3 Assuming file food.txt exists and you can read it, which of the following commands includes
string food.txt as part of its output?
ac
a. wc –c food.txt
b. cat food.txt | wc
c. wc food.txt
d. wc < food.txt

4 When you request the execution of a command on the command line by its filename, where does
the system certainly look for it?
ac
a. In the list of directories specified in the environment variable PATH.
b. In extreme cases, searching the whole hard disk might be deemed necessary. Fortunately for
performance, this does not occur very often.
c. In system directories such as /bin, /usr/bin and /usr/local/bin.
d. In your current directory.

5 Which of the following bash commands add the current directory to the command path?
d
a. PATH=.:PATH
b. PATH+='.'
c. PATH=.:$PATH
d. PATH=$PATH:.

6 Given the command line


MY_NAME=`whoami`
which of the following answers describes the way it is executed?
a
a. The system executes command whoami assigning its standard output as the value of shell
variable MY_NAME. The command’s standard output does not appear on the screen.
b. The system displays string “whoami‡ on the screen.
c. The system assigns string “whoamiâ€,€ to shell variable MY_NAME.
d. The system executes command whoami assigning its standard output as the value of shell
variable MY_NAME. The command’s standard output also regularly appears on the screen.

7 Which of the following are correct statements about the i-nodes?


abd
a. The i-node of a file contains the addressess of blocks containing the file’s content.
b. Important information about a file or directory is contained in an i-node. The content of the file or
directory is stored elsewhere.
c. The content of a file or directory is stored in an i-node.
d. The i-nodes of a partition are stored in a special list (sometimes called an array).

8 Which of the following are correct statements about the i-nodes?


c
a. To survive across user sessions, i-nodes are stored in a computer’s Read-Only Memory
(ROM).
b. The relative filename of a file is stored in its i-node.
c. The same i-node can be referred to by two or more filenames.
d. The i-node of a file contains the maximum size the file can expand to.

9 Assuming that a file system uses:


- file blocks of 4 KB each;
- i-nodes with 12 direct links, 1 singly-indirect link, 1 doubly-indirect link, 1 triply-indirect link.
What links of an i-node are used for a file of 96 KB size?
a
a. 12 direct links and 1 singly-indirect link.
b. 12 direct links.
c. 1 singly-indirect link.
d. 24 direct links.

10 Assuming that a file system uses:


- N.B.! file blocks of 8 KB each;
- block addresses of 4 B.
What is the maximum size of a file that can be obtained through the singly-indirect link?
b
a. 4 MB.
b. 16 MB.
c. 8 MB.
d. 4 GB.

11 Which of the following are correct statements about directories?


ab
a. The i-node of a directory is needed to know where the directory’s blocks are stored in the
partition.
b. A single directory may contain the same i-node number more than once.
c. For each of the files it contains, a directory stores the filename and the i-node number.
d. A directory is a special file that has no i-node.

12 Assuming file food.txt has 32 lines and cannot be read by you, what do you expect to see on
your screen when command
cat < food.txt | head -6
is executed?
d
a. Nothing, because of the piping with the head command.
b. 6.
c. The first six lines of the file.
d. The error message: "bash: food.txt: Permission denied"

13 Assuming file food.txt exists and you have all sorts of permissions, upon execution of command
head -6 < food.txt >> essentials.txt
ab
a. If file essentials.txt did not exist, it is created and the first 6 lines of food.txt are stored into it.
b. The first 6 lines of food.txt are appended at the end of file essentials.txt, if it existed.
c. If file essentials.txt did not exist, the first 6 lines of food.txt are displayed on the screen.
d. If file essentials.txt existed, its content is deleted before execution of command head.

14 Command
echo $(($((3 + 21)) * 100 - 50))
outputs:
a
a. 2350
b. 1200
c. 24 * 100 - 50
d. (3 + 21) * 100 - 50

15 Given the alphabet {a, b, c, d, 1, 2, 3}, the following are languages over it:
abcd
a. {abba, cab, bad}
b. {a, b, c, d, 1, 2, 3}.
c. {a, b, c, d, 1, 2}.
d. The empty set.

16 Choose which of the following strings match regular expression


x*y*z
abc
a. xxxxxxz
b. z
c. xxxyyyz
d. xy

17 Choose which of the following strings match regular expression


(11)* U (22)*
ab
a. 22
b. 1111
c. 111
d. 1122

18 Choose which of the following is the language generated by the regular expression
a(b U c)d
b
a. {ab, ac, bd, cd}
b. {abd, acd}
c. {a, ab, ac, bd, cd, d}
d. {ab, cd}
19 Which of the following statements about the grep command are true?
abd
a. Command grep with option –f interprets regular expressions.
b. Command grep with option –l prints names of argument files where matches have occurred.
c. Command: grep –f abc food.txt is generally slower than command: grep abc food.txt.
d. Command: grep abc food.txt prints all the lines of food.txt containing string abc at least once.

20 Which of the following statements about bash expansions are true?


abd
a. Parameter and variable expansion takes place before pathname expansion.
b. 12 is the output of the following command line:
echo `echo $((3 * 4))`
c. Command substitutions cannot be nested.
d. Command substitutions and arithmetic expansions take place in left-to-right order.