9.4.11 Practice Questions
You are using the vi editor to manage a text file on a Linux system. You want to type new text into the file. When you type, you want the existing text that comes after the cursor to be pushed down. Which mode provides this function?
> Insert Mode Explanation: In the vi editor, you need to switch to Insert Mode to be able to type new text in the file and have existing text that comes after the cursor pushed down. In Replace Mode, the existing text that comes after the cursor would be replaced when you typed new text. In Command Line Mode, you can enter commands to save the file and exit, exit the file without saving, save the file with a new name, or perform similar functions. In Command Mode, you can perform many useful editing tasks, such as cut, paste, copy, and more. There is no Text Mode in the vi editor.
Which command would you enter at the shell prompt to start a new Bourne-Again Shell (Bash) session?
> bash Explanation: The bash command opens a Bourne-Again Shell (Bash) session. Bash is the standard shell used in most Linux computers. It uses commands similar to a UNIX shell and includes: -Command completion -Command history -Improved arithmetic functions
A technician attempts to run an executable file on a Linux computer and receives a Permission Denied message. Which of the following commands should the technician use?
> chmod Explanation: The chmod command modifies the permissions on a files and defines who can access the file and the mode by which the file can be accessed. The grep command is used to search text. The ls command list the contents of a directory. The ps command lists information on the running processes on a Linux computer.
A technician uses the ps command to find information about a process that is running a browser application on a Linux computer. The technician knows the name of the process, but the list is very long. Which of the following commands would help the technician find and display only the information about the browser process?
> grep Explanation: The grep command is used to search text. The technician could save the output of the ps command in a text file and then search the files, or the technician could pipe the output from the ps command into the grep command. The ls command list the contents of a directory. The cd command is used to change the current directory or the directory in which the user is currently working. The sudo command is short for "superuser do" or "substitute user do." This command allows a user with proper permissions to execute a command as another user, such as a superuser.
What would you enter at the Command Prompt on a Linux system to display the IP addresses and subnet masks that are assigned to each network interface?
> ip Explanation: The ip or ifconfig command displays the IP addresses and subnet masks that are assigned to each network interface on a Linux system.
You want to know more about the usage, command syntax, and options available with the Linux cat command. What would you enter at the Command Prompt to display this information about the cat command?
> man cat Explanation: Entering man cat displays the manual page for the cat command. This command is very similar to the help screen, but provides more detail.
What would you enter at the shell prompt on a Linux system to display the present working directory?
> pwd Explanation: The pwd command displays the present working directory.
You would like to completely shut down a system 10 minutes after notifying all users of your intent. Which of the following commands should you enter at the shell prompt?
> shutdown -h +10 message Explanation: The correct answer is the shutdown -h +10 message command, which will shut down and power down the system 10 minutes after displaying the message to all users. The shutdown command shuts down or reboots a system in a secure manner. Listed below are options that work with this command. +m specifies when to perform the shutdown operation. m is the amount of time (specified in minutes). -h instructs the system to shut down and power down. -r instructs the system to reboot after the shutdown. -p powers off the machine. message specifies a message that is sent to all users that accompanies the standard shutdown notification. shutdown -p 10 message would power down the machine without properly shutting it down. The 10 is missing a + sign before it. shutdown -r +10 message would reboot (not shut down) the machine 10 minutes after displaying the message to the users. shutdown 10 -h message is incorrect syntax, and the 10 is missing the + sign.
You are the administrator for a Linux server. Following best practices for system security and effective administration, you always log in to the system with a standard non-root user account. You only elevate your privileges to root user level when you need to do an administrative task. What do you enter at the Command Prompt that will, by default, switch you to the root user and require you to enter the root password?
> su - Explanation: At the Command Prompt, enter the su - command so that the system will switch you to the root user and require you to enter the root password. You will then be able to perform tasks that require root user administrative privileges. After completing these tasks, you should log out as the root user and return to the standard user account.
While troubleshooting an issue with an Apache web server on your Linux system, you need to look at the last several entries in the log file. Which of the following tools would be best suited for this task? (Select two.)
> tail > cat Explanation: Both tail and cat are suited for this task. The tail command prints out the last 10 lines of a file by default. The cat command prints out the contents of a file. The dd command copies a file or device. The ls command is for listing the files in a directory. The head command prints out the first 10 lines of a file by default.