1.
What is a "man" page?
Correct Answer
C. A page detailing the usage and syntax of a particular Linux command.
Explanation
A "man" page refers to a page that provides detailed information about the usage and syntax of a specific Linux command. It serves as a manual or documentation resource for users, helping them understand how to effectively utilize the command and its various options. This page typically includes descriptions, examples, and other relevant details to assist users in performing tasks using the specific command.
2.
Which command below displays your current working directory?
Correct Answer
B. Pwd
Explanation
The command "pwd" stands for "print working directory" and is used to display the current working directory in a command line interface. It is commonly used in Unix-like operating systems, including Linux and macOS. By executing the "pwd" command, the user can easily identify the directory they are currently located in within the file system hierarchy.
3.
Which command below would change your location to the "/tmp" directory?
Correct Answer
A. Cd /tmp
Explanation
The correct answer is "cd /tmp". This command is used to change the current directory to the "/tmp" directory. The "cd" command stands for "change directory" and the "/tmp" specifies the directory path. By entering this command, the user's location will be changed to the "/tmp" directory.
4.
Which command below would list the contents of your current working directory?
Correct Answer
C. Ls
Explanation
The "ls" command is used in Unix-based systems to list the contents of the current working directory. It is the equivalent of the "dir" command in Windows. Therefore, selecting "ls" as the answer would display the contents of the current working directory.
5.
Which command(s) below can you use to view the contents of a text file? (Multiple correct answers, choose ALL that apply)
Correct Answer(s)
A. Cat
B. Less
C. More
E. Vi
F. View
Explanation
You can use the "cat" command, the "less" command, the "more" command, the "vi" command, and the "view" command to view the contents of a text file. The "cat" command displays the entire contents of the file, the "less" command allows you to scroll through the file, the "more" command displays the file one screen at a time, the "vi" command opens the file in a text editor where you can view and edit the contents, and the "view" command is similar to "vi" but it only allows you to view the file without editing it.
6.
Which command(s) below can you use to reboot the machine? (Multiple correct answers, choose ALL that apply)
Correct Answer(s)
A. Reboot
C. Shutdown -r now
E. Init 6
Explanation
The command "reboot" can be used to reboot the machine. The command "shutdown -r now" can also be used to reboot the machine. Additionally, the command "init 6" can be used to reboot the machine.
7.
Which command(s) below can you use to determine which user you are logged in as? (Multiple correct answers, choose ALL that apply)
Correct Answer(s)
A. Echo $user
C. Whoami
D. Id
Explanation
The command "echo $user" can be used to determine which user you are logged in as. The command "whoami" can also be used for the same purpose. Additionally, the command "id" can be used to determine the user's identity.
8.
Which command shows information about a Linux machine's filesystems and filesystem free space?
Correct Answer
B. Df -k
Explanation
The "df -k" command is used to display information about the filesystems on a Linux machine, including their sizes and the amount of free space available. The "-k" option is used to display the sizes in kilobytes. This command is commonly used to check the disk space usage on a system.
9.
How can you show a list of your previously entered commands, filtered for the string "service"? (Multiple correct answers, choose ALL that apply)
Correct Answer(s)
A. Cat ~/.bash_history | grep service
C. History | grep service
Explanation
The correct answers are "cat ~/.bash_history | grep service" and "history | grep service".
1. "cat ~/.bash_history | grep service" uses the "cat" command to display the contents of the "~/.bash_history" file, which contains a list of previously entered commands. The "|" (pipe) symbol is used to redirect the output of "cat" to the "grep" command, which filters the output for the string "service".
2. "history | grep service" uses the "history" command to display a list of previously entered commands. The "|" (pipe) symbol is used to redirect the output of "history" to the "grep" command, which filters the output for the string "service".
10.
The "sed" command can be used to manipulate text strings in a file or files, without having to edit the file manually. You are in a directory containing dozens of files., Some filesnames end with the .txt extension and some with the .cfg extension.
You want to replace the string "foo" with the string "bar" in every file ending in .txt using only one command. Which command below would accomplish that?
Correct Answer
C. Sed -i "s/foo/bar/" *.txt
Explanation
The correct answer is "sed -i "s/foo/bar/" *.txt" because the command uses the sed utility with the -i flag to edit files in-place, meaning it will modify the files directly without creating backup files. The "s/foo/bar/" argument is the substitution command, which replaces the string "foo" with "bar". The "*.txt" specifies that the command should only be applied to files with the .txt extension.