CompTIA Linux+ (XK0-004) — Question 132
A systems administrator clones copies of a Linux VM every time a new Linux server is needed. The administrator notices the command prompt always states localhost.localdomain.
Which of the following should the administrator run to have the command prompt consistently labeled as Server1 rather than localhost.localdomain?
Answer options
- A. host Server1
- B. echo "127.0.0.1 Server1 Server1.localdomain" >> /etc/hosts
- C. hostnamectl set-hostname "Server1" --pretty
- D. hostnamectl set-hostname Server1 --transient
- E. hostnamectl set-hostname Server1.localdomain --static
Correct answer: C
Explanation
The correct answer, C, sets the hostname to 'Server1' with a pretty name, which affects how the system presents its hostname. Options A and B do not change the system's hostname directly, while options D and E set transient and static hostnames, respectively, but do not provide the same user-friendly output as option C.