Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit


CYB234 Midterm Exam--Review

Fall 2023

Multiple-Choice: (1 point each; only one correct/best answer for each question)

1. To display your current location within the filesystem, you can type:

a. pwd        b.  dir     c. cwd   d. whereami

2. The command chmod 517 file1 would produce which of the following lines in the ls -l command?

a.  -r--r--rwx    1 user1    root        0 Apr 29 15:40 file

b. -r-x--xrwx    1 user1    root        0 Apr 29 15:40 file1

c. -rwx-w-rwx    1 user1    root        0 Apr 29 15:40 file1

d. -r-xrw-rwx    1 user1    root        0 Apr 29 15:40 file1

3. Which wildcard metacharacter stands for all the files in the current directory?

a. [a]           b.  !          c. *      d. [?]

4. The /usr/local/bin directory contains:

a. Essential administrative commands

b. Nothing; it is not a valid directory

c. The most fundamental commands that are essential for the operating system to function

d. Commands that have been compiled from local sources *

5. To decompress the archive example.gz, use the following command:

a. gunzip -x example.gz

b. gunzip example.gz *

c. gzip -x example.gz

d. gzip -u example.gz

6. Local variables are:

a. Only available to the shell they are created in *

b. Passed into other shells and commands

c. Are not a valid type of variable

d. Not used by shells at all

7.  The /bin directory contains:

a. Essential administrative commands

b. Nothing; it is not a valid directory

c. The most fundamental commands that are essential for the operating system to function

d. Commands that have been compiled from local sources *

8. Bash is:

a. a networking term

b. an operating system

c. a website

d. a shell

9. Which directory is used to store user home directories?

a. /usr

b. /homedir

c. /home

d. /tmp

10. Which regular expression character matches any one character?

a. .

b. +

c. ?

d. *

a. G

11. How can a user switch from the insert mode to the command mode in vi?

a.   :q! b. ESC c. switch d. TAB

12. How can you specify a text pattern that must be at the beginning of a line of text using regular expression?

a. Precede the string with a /

b. Follow the string with a \

c. Precede the string with a $

d. Precede the string with a ^

13. The Linux kernel is stored in _______ by default.

a. /kernel   b. /boot      c. /usr/kernel     d. /var/kernel      e. /etc/kernel

14. The default permissions given by the system prior to analyzing the umask are ___________for directories, and __________ for files.

a. rw-rw-rw- and rw-rw-rw-

b. rw-rw-rw- and r--r--r--

c. rw-rw-rw- and rwxrwxrwx

d. rwxrwxrwx and rw-rw-rw-

15. Which prompt does the root user receive when logged in to the system?

a.  $ b.  @ c.  # d.  !

16. A file has the following permissions -r----x-w-. The command chmod 256 would have the same effect as the following commands _________.

a. chmod u+x-r,g+r-x,o+w file1

b. chmod u=w,g=rx,o=rw file1

c. chmod u-r-x,g+r-w,o+r file1

d. chmod u-r+w,g+r,o+r file1

17. Which character at the beginning of a long listing indicates a directory?

a. –

b. l

c. c

d. d

18. Which command can be used to display the amount of free inodes that resides on a partition?

a. fdisk -li             b. df  -i        c. dh  -i           d. du  -i              e. lsblk

19. Given the following output from the ls command, how many files are linked with file1?

drwxr-xr-x    3 root     root         4096 Apr  8 07:12 Desktop

-rw-r--r--    3 root     root          282 Apr 29 22:06 file1

-rw-r--r--    1 root     root          282 Apr 29 22:06 file2

-rw-r--r--    4 root     root          282 Apr 29 22:06 file3

-rw-r--r--    2 root     root          282 Apr 29 22:06 file4

-rw-r--r--    1 root     root          282 Apr 29 22:06 file5

-rw-r--r--    1 user1    sys           282 Apr 29 22:06 file6

a. one                                    b.  two.

c.  three                                  d.  four

20. Which of the following information is not stored in a file's inode?

a. The file's modify time

b. The file's permissions

c. The file's user owner

d. The file's name

e. All of the above information is stored in the inode.


Short-Answers

1) Consider that the following output is generated by “ls -ali” command when executed in the current directory in this Linux environment:

54527022 drwxrwxrwx 3 cg    cg     65 Sep 22 19:09 .

50333228 drwxr-xr-x 6 cg    cg    137 May 29 07:49 ..

56733755 -rw-r--r-- 2 58617 58617 978 Sep 22 19:07 README.txt

4884029 drwxr-xr-x 2 58617 58617   6 Sep 22 19:09 mountain


a) Write a command to list the attributes of all the

files and directories in directory mountain:


b) If you see the same inode number assigned to three

files, f1, f2 & f3, what can you conclude?


c) Write a command (or piped commands) to list those files (not directories) where the owner has the

privilege to execute the files:


d) When was the parent directory created (per result of “ls -ali” command above)?


2) Very briefly state what the following commands will do:


a)   cat  f1  f2 :


b)  head   -10  f1:


c)  ln   f1  f3:


d) shutdown  -r  5


3) For each of the tasks given below list the Linux command (or piped commands) to accomplish the task:


a) Give group the privilege to modify file f1:


b) Display the current date & time:


c) List contents of file f1 with line numbers:


d) Get help for command “depth” to know more about it:



4) Write down the result of each of the commands below given the following contents of file f2 (write down “” if you think nothing will be listed):


Write down the result for each of the following 36 bold LISP expressions

when entered \bold in \bold the same CLISP environment

in the sequence as shown (write down ER

if you think that the old expression

will result in error):


a) grep  -wi   "\bold"    f2



b)  cat    f2   |   grep  -wn  '[E-R]'


//there is no whole word on its own consisting of a character from E-R


c) tail  -3   f2 |      grep   "LISP"


//LISP is not in the last three lines of the file


d)  grep  -n  '^.......*[0-9]\{1,5\}....*$'  f2




5) Consider the following contents of file, f2, when answering Parts a through b:


Write a function, name it as f, that accepts

a simple list of integers \992\ through \2023\ and returns the

corresponding list with only even integers included.

Assume that there is already a \function, named as odd2, for

your use which returns true if its argument is an odd integer,

otherwise it returns false.


a) Write down a grep command to list all the lines in file f2 with any word starting with a backslash, \, ignoring upper/lower case:




b) Write down a grep command to store all the lines of file f2, into file f3, containing the word “integer” as a whole word or part of a string ignoring upper/lower case:


Read Scripts

1.What will be printed by the following script