Which file defines the hostname in a Linux system?

Master the LPIC-3 300 Mixed Environment Exam with our tailored test. Utilize flashcards and multiple-choice questions, with each question offering in-depth hints and explanations. Prepare effectively and conquer your exam!

The correct choice is determined by understanding the role of various system configuration files in Linux.

The file that defines the hostname in a Linux system is located at /etc/hostname. This file is specifically designed to store the short hostname of the system. It is read during the boot process, and the system uses the content of this file to set the hostname properly. By default, it usually contains a single line with the hostname itself, which is crucial for network identification and various system services.

In contrast, the other files serve different purposes:

  • /etc/passwd lists user accounts and associated information, not the hostname.

  • /etc/hosts maps hostnames to IP addresses for local name resolution, but it does not define the hostname of the machine itself.

  • /etc/resolv.conf contains DNS resolver configuration information, detailing how a system resolves hostnames to IP addresses, but it does not specify the hostname of the system.

Thus, /etc/hostname is the correct file for defining the system's hostname, making it the right answer to the question.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy