Which of the following examples for Bash file globbing matches a file named root-can-do-this.txt when used in the directory holding that file? (Choose three correct answers.)
Correct Answer: B,D,E
Question 7
Which of the following files, located in a user's home directory, contains the Bash history?
Correct Answer: D
Explanation The correct answer is D, .bash_history. This file, located in a user's home directory, contains the Bash history, which is a list of commands that the user has entered in the Bash shell. The syntax of the file is: ~/.bash_history The ~ symbol represents the user's home directory, which is usually /home/username. The / symbol is a directory separator that separates the components of a path. The . symbol at the beginning of the file name indicates that the file is hidden, which means that it is not normally displayed by the ls command or the file manager, unless the -a option or the show hidden files option is used. The bash_history is the name of the file that stores the Bash history. The Bash history is maintained by the Bash shell while it is running, and it is written to the .bash_history file when the shell exits or when the history -a or -w options are used. The history command can be used to display, manipulate, or search the Bash history. The HISTFILE variable can be used to change the name or location of the .bash_history file. The HISTSIZE and HISTFILESIZE variables can be used to change the number of commands that are stored in the Bash history and the .bash_history file, respectively. The other files are incorrect for the following reasons: * A, .bashrc_history: This file does not exist by default, and it is not used to store the Bash history. The .bashrc file is a configuration file that is executed by the Bash shell when it starts in interactive mode. It can contain commands, aliases, functions, variables, or other settings that affect the behavior of the shell. However, it is not used to store the history of the commands that the user has entered. * B, .bash_histfile: This file does not exist by default, and it is not used to store the Bash history. The .bash_histfile file is not a standard file name, and it is not recognized by the Bash shell. The Bash shell uses the .bash_history file to store the history of the commands that the user has entered, unless the HISTFILE variable is changed to a different file name. * C, .history: This file does not exist by default, and it is not used to store the Bash history. The .history file is not a standard file name, and it is not recognized by the Bash shell. The Bash shell uses the .bash_history file to store the history of the commands that the user has entered, unless the HISTFILE variable is changed to a different file name. * E, .history_bash: This file does not exist by default, and it is not used to store the Bash history. The .history_bash file is not a standard file name, and it is not recognized by the Bash shell. The Bash shell uses the .bash_history file to store the history of the commands that the user has entered, unless the HISTFILE variable is changed to a different file name. References: * Where is bash's history stored? - Unix & Linux Stack Exchange * How to view the .bash_history file via command line? - Ask Ubuntu * shell - How can I see all of the bash history? - Stack Overflow
Question 8
Which of the following sequences in the vi editor saves the opened document and exits the editor? (Choose TWO correct answers.)
Correct Answer: A,D
Explanation To save a file and exit the vi/vim editor, you need to switch to command mode by pressing the Esc key, then type a colon (:) followed by a command. There are two commands that can save a file and quit the editor: x and wq. The x command writes the buffer to the file only if there are unsaved changes, while the wq command always writes the buffer to the file and updates the file modification time. Both commands are followed by an exclamation mark (!) to force the operation and override any warnings. Therefore, the correct sequences are: * Esc ZZ: This is equivalent to typing :x and hitting Enter. * Esc :wq!: This writes the buffer to the file and quits the editor, ignoring any warnings. The other options are incorrect because: * Ctrl :w! is not a valid sequence. The Ctrl key does not switch to command mode, and the w command only saves the file without exiting. * Esc zz is not a valid sequence. The zz command does not exist in vi/vim. * Ctrl XX is not a valid sequence. The Ctrl key does not switch to command mode, and the XX command does not exist in vi/vim. References: * How to Save a File in Vi / Vim Editor & Quit - phoenixNAP * How to Save a File in Vim / Vi and Quit the Editor | Linuxize * How To Save a File in Vi / Vim Text Editor - nixCraft * How to Save a File in Vi / Vim Editor & Quit - GeeksforGeeks
Question 9
Which command uninstalls a package but keeps its configuration files in case the package is re-installed?
Correct Answer: E
Question 10
A user accidentally created the subdirectory \dirin his home directory. Which of the following commands will remote that directory?