While using vi as superuser. the attempt to save a file while quitting the editor leads to an error indicating that the file is read-only. How can the file permissions be overridden to save the edits to the file and quit the editor?
Correct Answer: E
Explanation The wq! command is used to save a file and quit the vi editor, even if the file is read-only. The w command means write, the q command means quit, and the ! command means force. By combining these commands, the vi editor will override the file permissions and save the changes to the file, then exit the editor. The other options are either invalid syntax or do not force the write operation. For example, wq will save and quit only if the file is writable, ql will quit without saving, and fw! will force write but not quit. References: [vi] - FreeBSD vi(1) Manual Page [wq!] - How to save a file in vi / vim editor in Linux / Unix
Question 2
Which command can be used to display the local filesystems that are currently mounted'?
Correct Answer: B
Explanation The command df -h displays the disk space usage of all mounted filesystems in a human-readable format. It shows the size, used, available, and percentage of each filesystem, as well as the mount point. This command can be used to check the local filesystems that are currently mounted. https://unix.stackexchange.com/questions/24182/how-to-get-the-complete-and-exact-list-of-mounted-filesystems https://www.tecmint.com/find-mounted-file-systems-in-linux/ https://itslinuxfoss.com/check-filesystem-mounted-linux/
Question 3
What file contains values for MIBs which are set during system startup? (Specify the full name of the file, including path.)
Correct Answer:
/etc/rc.conf Explanation The file /etc/rc.conf contains values for Management Information Bases (MIBs) which are set during system startup. This file is used to configure system-wide settings, including the enabling and disabling of services, network settings, and other startup configurations2. References: FreeBSD Handbook - The FreeBSD Booting Process
Question 4
What symbol is used in the vi editor to start the forward search for a string? (Specify ONLY the single character symbol without any parameters)
Correct Answer:
/ Explanation The symbol / is used in the vi editor to start the forward search for a string. It is followed by the string to be searched and then Enter to execute the search. The vi editor highlights the first occurrence of the string after the cursor position. To find the next occurrence of the string in the same direction, press n. To find the previous occurrence of the string in the opposite direction, press N. References: How to Search to Find a Word in Vim or Vi Text Editor How can I switch from forward to backward search in Vim? How To Search in VI Editor How to Search in Vim / Vi
Question 5
Which of the following chmod commands changes the permission of the file text. txt to 750?
Correct Answer: E
Explanation Permissions involve read, write, and execute roles that can be assigned to the owner, a group, or other users1.To use the chmod command, you must specify the permission you want to set and the file or directory you want to modify1.For example,chmod +rwx filenameto add permissions,chmod -rwx directorynameto remove permissions, orchmod +x filenameto allow executable permissions2. There are two ways to specify the permissions with the chmod command: symbolic notation and numeric notation1.Symbolic notation uses letters and symbols to represent the user classes and the permissions1.Numeric notation uses octal numbers (0-7) to represent the permissions for each user class1.Each octal digit corresponds to a combination of read , write (w), and execute (x) permissions, as shown in the table below3: Octal digit Binary representation Permissions 0 000 - 1 001 -x 2 010 -w- 3 011 -wx 4 100 r- 5 101 r-x 6 110 rw- 7 111 rwx To use numeric notation, you need to provide three octal digits, one for each user class (owner, group, and others)1.For example,chmod 644 filenamemeans that the owner has read and write permissions (6), the group has read permissions (4), and others have read permissions (4)1. In this question, the desired permission for the file text.txt is 750, which means that the owner has read, write, and execute permissions (7), the group has read and execute permissions (5), and others have no permissions (0)1. Therefore, the correct chmod command to change the permission of the file text.txt to 750 ischmod text.txt 750. References:1: Chmod Command in Linux (File Permissions) | Linuxize2: How to change directory permissions in Linux | Pluralsight3: How to Use the chmod Command on Linux - How-To Geek