Unit 2 - Practice Quiz

CSC202

1 Which command is used to change the permissions of a file or directory in Linux?

A. chown
B. chmod
C. chgrp
D. umask

2 In the permission string drwxr-xr-x, what does the first character d represent?

A. It is a directory
B. It is a deleted file
C. It is a device file
D. It is a default permission

3 What is the octal representation of the permission rwxr-x---?

A. 751
B. 750
C. 740
D. 650

4 Which command allows you to change the owner of a file?

A. chmod
B. passwd
C. chown
D. groupadd

5 If the umask value is set to 022, what will be the default permissions for a newly created directory?

A. 777
B. 755
C. 644
D. 666

6 Which command is used to view the Access Control Lists (ACLs) of a file?

A. ls -l
B. getfacl
C. setfacl
D. chmod

7 What does the Sticky Bit do when applied to a directory?

A. It prevents users from deleting the directory.
B. It allows only the file owner, the directory owner, or root to delete or rename files within that directory.
C. It ensures files created inside inherit the group ownership of the directory.
D. It allows the script to run with the permissions of the file owner.

8 Which numeric value represents the Read permission?

A. 1
B. 2
C. 4
D. 6

9 Which symbol indicates that a file has an Access Control List (ACL) set when viewing permissions via ls -l?

A. *
B. @
C. +
D. #

10 Which command allows you to modify the Access Control List (ACL) of a file?

A. modacl
B. changeacl
C. getfacl
D. setfacl

11 What is the purpose of the SUID (Set User ID) bit on an executable file?

A. It prevents the file from being deleted.
B. It executes the file with the permissions of the file owner, not the user running it.
C. It executes the file with the permissions of the group owner.
D. It caches the file in swap memory.

12 How is the SGID (Set Group ID) permission represented in the symbolic mode when set on a directory?

A. An s in the user execute position.
B. An s in the group execute position.
C. A t in the other execute position.
D. A g in the group read position.

13 Which command would you use to recursively change the owner of a directory and all its contents to user webadmin?

A. chown -r webadmin directory
B. chown -R webadmin directory
C. chmod -R webadmin directory
D. chgrp -r webadmin directory

14 According to the Filesystem Hierarchy Standard (FHS), which directory contains system-wide configuration files?

A. /bin
B. /dev
C. /etc
D. /usr

15 Which directory is strictly used for variable data files such as logs and spool files?

A. /tmp
B. /var
C. /proc
D. /opt

16 What is the result of the command chmod u+x script.sh?

A. Adds execute permission for the user (owner).
B. Adds execute permission for the group.
C. Adds execute permission for everyone.
D. Sets the SUID bit.

17 Which command creates a symbolic (soft) link named linkname pointing to targetfile?

A. ln targetfile linkname
B. ln -s targetfile linkname
C. link targetfile linkname
D. cp -l targetfile linkname

18 What happens if you delete the source file of a hard link?

A. The hard link becomes broken and unusable.
B. The hard link allows access to the data as long as the link exists.
C. The hard link is automatically deleted.
D. The file system becomes corrupted.

19 Which command is used to remove a directory that is not empty?

A. rmdir directory
B. rm directory
C. rm -r directory
D. del directory

20 Which command is used to update the access and modification timestamps of a file, or create it if it doesn't exist?

A. cat
B. touch
C. nano
D. mkfile

21 Which command helps determine the file type of a file based on its content (magic numbers), rather than its extension?

A. ls
B. type
C. file
D. stat

22 Which directory typically contains device files representing hardware components?

A. /mnt
B. /dev
C. /proc
D. /sys

23 Which find command syntax searches for files named 'report.txt' in the current directory and subdirectories?

A. find . -name report.txt
B. locate report.txt
C. find report.txt
D. search -f report.txt

24 Which command is significantly faster than find because it searches a pre-built database?

A. grep
B. which
C. locate
D. whereis

25 What is the purpose of the which command?

A. To find where the manual pages for a command are.
B. To locate the executable binary of a command in the user's $PATH.
C. To search for text within files.
D. To list all files in a directory.

26 In the vi or vim editor, which key acts as a toggle to switch from Insert mode back to Command mode?

A. Enter
B. Ctrl
C. Esc
D. Shift

27 Which command combination in vi saves the file and quits the editor?

A. :q!
B. :w
C. :wq
D. :exit

28 Which command prints the last 10 lines of a file to standard output?

A. head
B. tail
C. cat
D. less

29 Which command is used to search for a specific text pattern within a file?

A. find
B. grep
C. locate
D. sed

30 What does the wc -l command do?

A. Counts the number of words in a file.
B. Counts the number of characters in a file.
C. Counts the number of lines in a file.
D. Lists the file permissions.

31 How do you specify a Set Group ID (SGID) bit using octal mode for a directory permission of 755?

A. chmod 1755 directory
B. chmod 2755 directory
C. chmod 4755 directory
D. chmod 0755 directory

32 Which command is used to create a new directory, including parent directories if they do not exist (e.g., mkdir -p /a/b/c)?

A. mkdir -r
B. mkdir -p
C. mkdir -f
D. touch -d

33 What does the command cp -a source dest do?

A. Copies only the attributes, not the data.
B. Copies files in archive mode, preserving permissions, ownership, and timestamps.
C. Copies files interactively, asking before overwriting.
D. Copies files only if the source is newer.

34 In the Linux file system, what is the top-level directory called?

A. Home
B. Root
C. Base
D. Master

35 Which command lets you view the contents of a large text file one page/screen at a time, allowing backward navigation?

A. cat
B. head
C. more
D. less

36 Which command will sort the contents of a text file alphabetically?

A. order
B. sort
C. arrange
D. grep

37 When using ls -l, a file permission of rw-rw-rw- implies:

A. Everyone can read and write.
B. Only the owner can read and write.
C. No one can execute the file.
D. Both A and C.

38 Which character represents the user's home directory in a shell path?

A. .
B. ..
C. ~
D. /

39 What does the command chmod g-w file.txt do?

A. Grants write permission to the group.
B. Removes write permission from the group.
C. Removes write permission from the owner.
D. Grants write permission to the guest user.

40 Which directory contains the Linux kernel and boot loader files?

A. /sys
B. /boot
C. /root
D. /kern

41 To force vi to quit without saving changes, which command is used?

A. :q
B. :q!
C. :w!
D. :x

42 What is the purpose of the /proc directory?

A. It stores processor drivers.
B. It is a virtual filesystem providing process and kernel information.
C. It contains procedures for system startup.
D. It holds user profiles.

43 Which find command option allows you to execute a command on every file found?

A. -run
B. -exec
C. -do
D. -action

44 What is the result of the umask command without arguments?

A. It resets the permissions to 777.
B. It displays the current umask value.
C. It sets the file mode to read-only.
D. It changes the user mask to root.

45 Which command moves a file from one location to another or renames it?

A. mv
B. cp
C. rn
D. rm

46 How do you allow a specific user, john, read and write access to file.txt using ACLs without changing the file's group owner?

A. chmod u+rw file.txt
B. chown john file.txt
C. setfacl -m u:john:rw file.txt
D. setfacl -x u:john file.txt

47 What is the function of the head -n 5 filename command?

A. Displays the last 5 lines of the file.
B. Displays the first 5 lines of the file.
C. Displays the 5th line of the file.
D. Deletes the first 5 lines of the file.

48 When listing files with ls -la, the entries . and .. represent:

A. Hidden files.
B. The current directory and the parent directory, respectively.
C. System configuration files.
D. Temporary link files.

49 Which permission bit prevents a standard user from executing a directory (i.e., cd into it)?

A. Read (r)
B. Write (w)
C. Execute (x)
D. Sticky (t)

50 What is the binary representation of the permission set r-x?

A. 101
B. 110
C. 011
D. 111