Which command is used to set the hostname of the local system? (Specify ONLY the command without any path or parameters.)
Correct Answer:
hostname Explanation: The hostname command is used to set the hostname of the local system. The hostname command can take a single argument, which is the new hostname to be assigned to the system. For example, to set the hostname to linux, one can run: hostname linux The hostname command can also be used without any arguments to display the current hostname of the system. For example, to show the current hostname, one can run: hostname The hostname command only changes the hostname temporarily, meaning that the original hostname will be restored after a reboot. To change the hostname permanently, one has to edit the configuration files that store the hostname information, such as /etc/hostname, /etc/hosts, /etc/sysconfig/network, etc. The exact files and commands may vary depending on the Linux distribution and the system initialization process. For more details, please refer to the web search results1 or the question answering results2. Reference:
Question 17
Which configuration file would be edited to change the default options for outbound SSH sessions?
Correct Answer: D
The /etc/ssh/ssh_config file is the global configuration file for the OpenSSH client. It contains the default values for the options that apply to all outbound SSH sessions initiated from the system. The options in this file can be overridden by the user's configuration file (~/.ssh/config) or by command-line arguments. The /etc/ssh/sshd_config file is the configuration file for the OpenSSH server, and it does not affect outbound SSH sessions. The other options are not valid configuration files for OpenSSH. Reference: LPIC-1 Exam 102 Objectives, Topic 110: Security, 110.3 Perform security administration tasks, Key Knowledge Areas: Basic client-side DNS configuration, Configure SSH and remote X [OpenSSH manual page], FILES section, /etc/ssh/ssh_config description
Question 18
What output will the following command sequence produce? echo '1 2 3 4 5 6' | while read a b c; do echo result: $c $b $a; done
Correct Answer: E
The while loop reads a line from the standard input and splits it into words using the IFS variable, which by default contains spaces, tabs, and newlines. The read command assigns the first word to the variable a, the second word to the variable b, and the rest of the line to the variable c. Therefore, in this case, a=1, b=2, and c=3 4 5 6. The echo command prints the values of c, b, and a in reverse order, separated by spaces. The output is result: 3 2 1. The loop terminates after reading the first line, since there is no more input to read. References: Bash while Loop | Linuxize, Bash Scripting - While Loop - GeeksforGeeks
Question 19
Which of the following crontab entries will execute myscript at 30 minutes past every hour on Sundays?
Correct Answer: D
The correct crontab entry for executing myscript at 30 minutes past every hour on Sundays is D. 30 0-23 * * 0 myscript. This is because the crontab format consists of six fields: minute, hour, day of month, month, day of week, and command. The values for each field can be: * A single number, such as 5 or 10. * A range of numbers, such as 1-5 or 10-15. * A list of numbers separated by commas, such as 1,3,5 or 10,12,14. * An asterisk (*), which means all possible values for that field. * A step value, which means every nth value for that field, such as */5 or 10-20/2. The day of week field can be either a number from 0 to 6, where 0 and 7 are Sunday, or a three-letter abbreviation, such as SUN or MON. The month field can be either a number from 1 to 12, or a three-letter abbreviation, such as JAN or FEB. In this case, the crontab entry D. 30 0-23 * * 0 myscript means: * 30: Execute the command at the 30th minute of every hour. * 0-23: Execute the command for every hour from 0 (midnight) to 23 (11 PM). * *: Execute the command for every day of the month, regardless of the month. * *: Execute the command for every month, regardless of the year. * 0: Execute the command only on Sundays. The other options are either incorrect or do not match the requirement. For example, option A. 0 * * * 30 myscript means: * 0: Execute the command at the 0th minute of every hour. * *: Execute the command for every hour of the day. * *: Execute the command for every day of the month, regardless of the month. * *: Execute the command for every month, regardless of the year. * 30: Execute the command only on the 30th day of the week, which is invalid. References: * Crontab Explained in Linux [With Examples] * 'crontab' in Linux with Examples - GeeksforGeeks * Crontab Syntax on Linux + Useful Examples - Hostinger
Question 20
Which of the following can the chage command NOT change?
Correct Answer: E
The chage command can change the following parameters related to user password expiry and aging: The last password change date (-d or --lastday option) The password expiry date (-E or --expiredate option) The minimum number of days between password changes (-m or --mindays option) The maximum number of days during which a password is valid (-M or --maxdays option) The number of days of warning before password expires (-W or --warndays option) The chage command cannot change the number of days of inactivity after a password has expired before the account is locked. This parameter is controlled by the -I or --inactive option of the usermod command, which modifies the user account information. The chage command only displays the current value of this parameter, but does not allow changing it. Reference: chage command in Linux with examples - GeeksforGeeks 10 chage command examples in Linux [Cheat Sheet] - GoLinuxCloud How to Use the Chage Command in Linux - TecAdmin How to Manage User Password Expiration and Aging in Linux - Tecmint