Unit 2 - Practice Quiz

CSC202 51 Questions
0 Correct 0 Wrong 51 Left
0/51

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

Configuring Permissions: Configure standard Linux permissions Easy
A. passwd
B. chmod
C. chgrp
D. chown

2 What is the primary function of the mkdir command?

Implementing File Management: Use file management commands Easy
A. To list the contents of a directory
B. To remove a directory
C. To create a new directory
D. To move a directory

3 Which command displays the entire content of a text file on the standard output?

Authoring Text Files: Manage text files Easy
A. head
B. cat
C. less
D. tail

4 In the standard Linux Filesystem Hierarchy, which directory is the top-level root of the entire file system?

Implementing File Management: Understand the Linux file system Easy
A. /home
B. /
C. /root
D. /bin

5 Which command would you use to find the exact location of an executable program like python in your system's PATH?

Implementing File Management: Find file locations Easy
A. where
B. locate
C. find
D. which

6 Which of the following is a widely used, simple-to-use command-line text editor often recommended for beginners?

Authoring Text Files: Edit text files Easy
A. emacs
B. nano
C. vim
D. sed

7 In the permission string -rwxr-x---, what permissions does the 'group' have?

Configuring Permissions: Configure standard Linux permissions Easy
A. Read and write
B. Read and execute
C. No permissions
D. Only execute

8 What does the cp command do?

Implementing File Management: Use file management commands Easy
A. Copies files and directories
B. Moves files and directories
C. Changes file permissions
D. Creates new files

9 What is the primary purpose of the 'sticky bit' permission when set on a directory?

Configuring Permissions: Configure special Linux permissions Easy
A. It prevents anyone from writing to the directory.
B. It causes any program executed from the directory to run with the directory owner's permissions.
C. It ensures only the file's owner (or root) can delete or rename the file within that directory.
D. It makes all new files in the directory inherit the directory's group.

10 Which directory typically contains essential system configuration files?

Implementing File Management: Understand the Linux file system Easy
A. /etc
B. /var
C. /bin
D. /home

11 To display only the last few lines of a file, which command is most appropriate?

Authoring Text Files: Manage text files Easy
A. more
B. tail
C. head
D. cat

12 What is the main advantage of using Access Control Lists (ACLs) over standard Linux permissions?

Configuring Permissions: Configure access control lists Easy
A. They are the only way to set read, write, and execute permissions.
B. They completely replace the need for chmod.
C. They are simpler to understand than standard permissions.
D. They allow for more granular permissions for multiple specific users and groups.

13 The locate command is often faster than find because it...

Implementing File Management: Find file locations Easy
A. scans the hard drive's index directly.
B. can only find executable files.
C. only searches the current directory.
D. searches a pre-built database of file locations.

14 Which command is used to remove a file in Linux?

Implementing File Management: Use file management commands Easy
A. rm
B. del
C. erase
D. remove

15 When the SUID (Set User ID) bit is set on an executable file, what happens when a user runs it?

Configuring Permissions: Configure special Linux permissions Easy
A. The file executes with the permissions of the file's group.
B. The file's user ID is changed permanently.
C. The file executes with the permissions of the file's owner, not the user who ran it.
D. The file can only be executed by its owner.

16 Which command is used to view the Access Control Lists (ACLs) for a file named data.txt?

Configuring Permissions: Configure access control lists Easy
A. getfacl data.txt
B. showacl data.txt
C. ls -la data.txt
D. setfacl data.txt

17 In the vim text editor, which key is typically pressed to switch from Insert mode (where you type text) to Normal mode (where you enter commands)?

Authoring Text Files: Edit text files Easy
A. Escape (Esc)
B. Tab
C. Control (Ctrl)
D. Enter

18 What is the purpose of the chown command?

Configuring Permissions: Configure standard Linux permissions Easy
A. To change the permissions of a file.
B. To create a new user.
C. To change the user and/or group ownership of a file.
D. To switch to a different user account.

19 How can you create a new, empty file named newfile.log from the command line without opening an editor?

Implementing File Management: Use file management commands Easy
A. create newfile.log
B. mkdir newfile.log
C. cat > newfile.log
D. touch newfile.log

20 In the Linux Filesystem Hierarchy Standard (FHS), where are user home directories typically created?

Implementing File Management: Understand the Linux file system Easy
A. /usr
B. /home
C. /root
D. /etc

21 A directory named /shared/projectA needs to be configured so that members of the developers group can create, delete, and modify files within it, but they should not be able to delete or rename files created by other users in that directory. Which combination of commands will achieve this?

Configuring Permissions: Configure standard Linux permissions Medium
A. chmod 1770 /shared/projectA && chgrp developers /shared/projectA
B. chmod 770 /shared/projectA && chgrp developers /shared/projectA
C. setfacl -m g:developers:rwx /shared/projectA
D. chmod g+rws,o-rwx /shared/projectA

22 You need to create a compressed archive of the /var/log directory, naming it logs_backup.tar.gz and placing it in the /tmp directory. You want to see the files being added to the archive as the command runs. Which command accomplishes this?

Implementing File Management: Use file management commands Medium
A. gzip -c /var/log > /tmp/logs_backup.tar.gz
B. tar -xvf /tmp/logs_backup.tar.gz /var/log
C. tar -cvzf /tmp/logs_backup.tar.gz /var/log
D. zip -r /tmp/logs_backup.zip /var/log

23 You have two sorted text files, list1.txt and list2.txt. You want to find the lines that are present in list1.txt but NOT in list2.txt. Which command will give you the desired output?

Authoring Text Files: Manage text files Medium
A. comm -12 list1.txt list2.txt
B. diff list1.txt list2.txt
C. comm -23 list1.txt list2.txt
D. grep -vf list2.txt list1.txt

24 A system administrator needs to find all files in the /home directory that are larger than 100MB and have not been accessed in the last 90 days. Which find command is correct?

Implementing File Management: Find file locations Medium
A. locate /home --size=+100M --atime=+90
B. find /home -size 100M -mtime 90
C. find /home -size +100M -atime +90
D. find /home -size +100M -ctime -90

25 You have a directory /data/collaboration where multiple users from the editors group need to work. You want to ensure that any new file or subdirectory created within /data/collaboration automatically inherits the group ownership of the parent directory (editors), rather than the primary group of the user who created it. Which command would you use?

Configuring Permissions: Configure special Linux permissions Medium
A. chmod g+s /data/collaboration
B. setfacl -d -m g:editors:rwx /data/collaboration
C. chmod u+s /data/collaboration
D. chmod +t /data/collaboration

26 A file /srv/app/config.xml has standard permissions of 640 (rw-r-----) and is owned by appuser:appgroup. You need to grant read-only access to a specific user, auditor, who is not in appgroup, without changing the base permissions. What is the correct command?

Configuring Permissions: Configure access control lists Medium
A. setfacl -m u:auditor:r-- /srv/app/config.xml
B. setfacl -m g:auditor:r-- /srv/app/config.xml
C. chmod o+r /srv/app/config.xml
D. usermod -a -G appgroup auditor

27 While editing a configuration file in vim, you are in Normal mode and want to delete the current line and the 4 lines below it (5 lines total). Which command will accomplish this?

Authoring Text Files: Edit text files Medium
A. 5dd
B. 5x
C. d5j
D. d5w

28 A system administrator runs df -h and sees the / partition is 100% full. After deleting a 10GB log file, df -h still shows the partition as 100% full. What is the most likely reason for this and how can it be resolved?

Implementing File Management: Understand the Linux file system Medium
A. The filesystem is corrupt and requires an fsck on the next reboot.
B. The user does not have permission to delete the file, so it was moved to a trash directory.
C. A process still has an open file handle to the deleted file; the space will be freed after restarting the service that wrote the log.
D. The ext4 journaling feature is holding the space; it will be released after a few minutes automatically.

29 A user runs ls -l and sees the following permission string for a file: -r-sr-xr-x. What does the 's' in the owner's permissions signify?

Configuring Permissions: Configure standard Linux permissions Medium
A. The sticky bit is set.
B. The SUID (Set User ID) bit is set, and the owner has execute permission.
C. The SGID (Set Group ID) bit is set.
D. The file is a symbolic link.

30 You need to count the number of unique IP addresses that have accessed a web server, based on an access.log file where the IP address is the first field on each line. Which of the following command pipelines is the most efficient way to do this?

Authoring Text Files: Manage text files Medium
A. cut -d' ' -f1 access.log | sort -u | wc -l
B. awk '{print $1}' access.log > ips.txt && sort ips.txt | uniq | wc -l
C. grep -oE '^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}' access.log | wc -l
D. cat access.log | sort | uniq | wc -l

31 You are looking for a configuration file named httpd.conf. You are not sure of its exact location, but you know it's somewhere in the /etc directory tree. The system has a mlocate database that is updated nightly. What is the fastest command to find the file's path?

Implementing File Management: Find file locations Medium
A. locate httpd.conf | grep /etc
B. grep -r httpd.conf /etc
C. which httpd.conf
D. find / -name httpd.conf

32 You have a directory containing hundreds of files with the extension .jpeg. You need to rename all of them to have the extension .jpg. Which of the following is a correct and efficient way to perform this bulk rename?

Implementing File Management: Use file management commands Medium
A. ls *.jpeg | xargs -I {} mv {} {}.jpg
B. for f in *.jpeg; do mv -- "{f%.jpeg}.jpg"; done
C. rename .jpeg .jpg *
D. mv .jpeg .jpg

33 You want to set default ACLs on a directory /data/share so that any new file created in it will automatically grant read/write permissions to the analysts group. Which command would you use?

Configuring Permissions: Configure access control lists Medium
A. setfacl -m g:analysts:rw /data/share
B. chown :analysts /data/share
C. setfacl -m d:g:analysts:rw /data/share
D. chmod g+rw /data/share

34 What is the primary purpose of the /proc filesystem in Linux?

Implementing File Management: Understand the Linux file system Medium
A. It contains log files for all system services and the kernel.
B. It stores system-wide configuration files.
C. It is the primary location for temporary files created by processes.
D. It is a virtual filesystem that provides an interface to kernel data structures and process information.

35 You are in vim and want to copy the entire contents of the current file and paste it into a new file named new_config without closing vim. What sequence of commands would achieve this?

Authoring Text Files: Edit text files Medium
A. ggVG"y :new new_config "p
B. ggdG :e new_config p
C. :%y | :e new_config | :p
D. :w! new_config

36 After running ls -l /usr/bin/passwd, you see the permissions -rwsr-xr-x. A security audit requires you to explain the implication of the 's' in this permission string. What is its function?

Configuring Permissions: Configure special Linux permissions Medium
A. It sets the SGID bit, so the command runs with the group permissions of the file's group.
B. It allows any user who runs the passwd command to execute it with the permissions of the file's owner (root), which is necessary to modify the protected /etc/shadow file.
C. It is the sticky bit, which prevents users from deleting the passwd executable.
D. It indicates that the file is a 'secure' executable that cannot be modified.

37 You need to view the last 20 lines of a log file named application.log and continue to monitor the file for any new lines that are added in real-time. Which command should you use?

Authoring Text Files: Manage text files Medium
A. tail -f -n 20 application.log
B. cat application.log | tail -20f
C. tail -n 20 -f application.log
D. head -n 20 application.log && watch tail application.log

38 What is the effect of the umask 0077 command on newly created files and directories?

Configuring Permissions: Configure standard Linux permissions Medium
A. Files will be created with 666 permissions and directories with 777 permissions.
B. Files will be created with 600 (rw-------) permissions and directories with 700 (rwx------) permissions, making them private to the owner.
C. It prevents any new files or directories from being created.
D. Files will be created with 077 permissions and directories with 077 permissions.

39 You want to copy a directory /source/data to /backup/data while preserving permissions, ownership, and timestamps. You also want to see a progress bar for large files. Which rsync command is most appropriate?

Implementing File Management: Use file management commands Medium
A. tar -cf - /source/data | (cd /backup/ && tar -xpf -)
B. rsync -avh --progress /source/data /backup/
C. cp -Rpf /source/data /backup/data
D. rsync -cpr /source/data /backup/

40 You need to find all zero-byte (empty) files within your home directory (~/) and delete them. Which of the following one-line commands will safely accomplish this?

Implementing File Management: Find file locations Medium
A. find ~/ -size 0 | xargs rm
B. find ~/ -type f -empty -delete
C. rm find ~/ -size 0
D. ls -lR ~/ | grep ' 0 ' | awk '{print $9}' | xargs rm

41 A file report.docx has standard permissions of 640 (-rw-r-----) and is owned by alice:project. An administrator applies an ACL. The output of getfacl report.docx is:


# file: report.docx
# owner: alice
# group: project
user::rw-
user:bob:rwx
group::r--
group:auditors:r-x
mask::r--
other::---


What are the effective permissions for the user bob?

Configuring access control lists Hard
A. r--
B. No permissions
C. rw-
D. rwx

42 A directory /data/collaboration is set up with permissions 3775 (drwxrwsr-t). User carol (primary group users, secondary group devs) creates a new file named notes.txt inside this directory. Her current umask is 0027. What will be the final owner, group, and permissions of notes.txt?

Configuring special Linux permissions Hard
A. owner: root, group: collaboration, perms: -rwxr-x---
B. owner: carol, group: collaboration, perms: -rw--w----
C. owner: carol, group: collaboration, perms: -rw-r-----
D. owner: carol, group: users, perms: -rw-r-----

43 You need to find all regular files in /var/log that are larger than 50MB, have not been accessed in the last 90 days, and are owned by the user syslog. For maximum efficiency, you want to pass this list of files to the gzip command, minimizing the number of gzip processes spawned. Which command is the most appropriate and efficient?

Find file locations Hard
A. find /var/log -type f -user syslog -size +50M -atime +89 -exec gzip {} +
B. gzip $(find /var/log -type f -user syslog -size +50M -atime +89)
C. find /var/log -type f -user syslog -size +50M -atime +89 | xargs gzip
D. find /var/log -type f -user syslog -size +50M -atime +89 -exec gzip {} \;

44 A process has an open file descriptor for /tmp/data.log. An administrator then runs mv /tmp/data.log /var/log/data.log. What is the state of the process's file descriptor and what happens when the process writes new data?

Implementing File Management: Understand the Linux file system Hard
A. The file descriptor points to a new inode created at /var/log/data.log, and writes are redirected.
B. The file descriptor becomes invalid, and the process's writes are lost.
C. The process receives an error on the next write because the file path has changed.
D. The file descriptor remains valid and points to the same inode; new data is written to /var/log/data.log.

45 Using vim, you want to copy lines 10 through 20 from the current file and paste them immediately after line 50. However, you want the pasted text to have its automatic indentation adjusted relative to line 50. Which sequence of commands achieves this?

Authoring Text Files: Edit text files Hard
A. :10,20y followed by 50G and then ]p
B. :10,20co 50 then 51G followed by =
C. :10,20t50
D. :10,20m50

46 A user's umask is set to 0027. What will be the permissions of a new directory and a new file created by this user, respectively, assuming no other permission-altering mechanisms are in place?

Configuring standard Linux permissions Hard
A. Directory: 755, File: 644
B. Directory: 750, File: 640
C. Directory: 777, File: 666
D. Directory: 770, File: 660

47 You have a file data.csv with comma-separated values. You need to swap the first and third columns for every line in the file and write the result to new_data.csv. Which awk command correctly performs this operation?

Authoring Text Files: Manage text files Hard
A. sed 's/([^,]*),([^,]*),([^,]*)/\3,\2,\1/' data.csv > new_data.csv
B. awk -F, '{OFS=","; t=1=3=t; print}' data.csv > new_data.csv
C. awk '{print $3, $2, $1}' data.csv > new_data.csv
D. awk -F, '{print $3, $1}' data.csv > new_data.csv

48 You want to create a full backup of /home/user to /mnt/backup, ensuring that all file attributes (permissions, timestamps, ownership) are preserved. You also want the transfer to be efficient by only copying changed files, deleting files from the backup that no longer exist in the source, and showing a progress summary. Which rsync command is the most complete and correct for this scenario?

Implementing File Management: Use file management commands Hard
A. rsync -a --delete --info=progress2 /home/user/ /mnt/backup/
B. rsync -rltpgoD --del --progress /home/user/ /mnt/backup/
C. cp -aR --update /home/user /mnt/backup
D. rsync -av --delete /home/user /mnt/backup

49 A directory /shared has a default ACL set on it. A user creates a new file test.txt inside /shared. What will be the relationship between the directory's default ACL and the new file's access ACL?

Configuring access control lists Hard
A. The file's access ACL will be identical to the directory's access ACL.
B. The file will inherit the directory's default ACL as its own default ACL.
C. The file's access ACL will be identical to the directory's default ACL, but the file's mask will be recalculated based on its initial group permissions.
D. The file will not have an ACL, only standard permissions.

50 An administrator sets the SUID bit on a shell script (-rwsr-xr-x /usr/local/bin/myscript.sh). The script contains the command rm /tmp/log. When a non-root user executes /usr/local/bin/myscript.sh, what is the most likely outcome on a modern, security-conscious Linux system?

Configuring special Linux permissions Hard
A. The system prompts for the root password before executing the script.
B. The script runs with the user ID of the person who executed it, likely failing to remove a root-owned log file.
C. The script fails to execute with a 'Permission Denied' error.
D. The script runs with the effective user ID of the file's owner (root), successfully executing rm /tmp/log.

51 You need to locate all symbolic links within the /etc directory tree that are broken (i.e., their target does not exist). Which of the following commands is the most direct and accurate way to do this?

Find file locations Hard
A. find /etc -type l -exec test -e {} \; -print
B. find /etc -xtype l
C. ls -lR /etc | grep '^l' | grep '-> /nonexistent'
D. find /etc -type l ! -exec test -e {} \;