102-500 Exam QuestionsBrowse all questions from this exam

102-500 Exam - Question 1


FILL BLANK -

Which command is used to set the hostname of the local system? (Specify only the command without any path or parameters.)

Show Answer
Correct Answer:

The command to set the hostname of the local system is 'hostname'. This command allows you to both display and set the system's hostname. However, note that if you want to permanently change the hostname on a modern system using systemd, 'hostnamectl' with the 'set-hostname' parameter might be more appropriate. Without additional context or parameters, 'hostname' is the direct answer to the question.

Discussion

17 comments
Sign in to comment
lucaverce
May 30, 2022

I took my exam today and I answer "systemctl" Passed with 800/800 (100% correct)

ngotru97
Jun 3, 2022

How change with "systemctl" bro

MaikyCR28
Jun 15, 2022

Congrats bro. I'll take the exam in 3 weeks. I haven't almost found test exams to practice in Google. How did you got ready to take it?

danny12233
Jan 17, 2023

There is no way to set the hostname via systemctl, check the command line options for systemctl, hostname isn't mentioned. The answer is absolutely hostnamectl. don't speared misinformation

lucaverce
Feb 14, 2023

you're right

k3n_
Apr 15, 2024

The only way a ctl is involved with changing hostname is through: ~]# hostnamectl set-hostname name

Rini_Giannenzo
Dec 14, 2020

Anche hostnamectl lo fa [con meno sethostname

isaac_paul
Dec 16, 2021

hostname is the correct answer

drliu1202
Aug 3, 2022

"There is also a command hostname, with which you can show or set the system’s host name." https://learning.lpi.org/en/learning-materials/010-160/2/2.1/2.1_01/#:~:text=There%20is%20also%20a%20command%20hostname%2C%20with%20which%20you%20can%20show%20or%20set%20the%20system%E2%80%99s%20host%20name.

lucaverce
May 25, 2022

Using the hostnamectl is a better and permanent choice, but for name change is needed the sub-command "set-hostname" or "hostname" following the command. example: TestVM@Ubuntu-VM:~$ hostnamectl set-hostname TestVM2 this other form is accepted TestVM@Ubuntu-VM:~$ hostnamectl hostname TestVM3 So we will enter two command followed by an argument. MAN page for hostnamectl: HOSTNAMECTL(1) hostnamectl HOSTNAMECTL(1) NAME hostnamectl - Control the system hostname SYNOPSIS hostnamectl [OPTIONS...] {COMMAND} DESCRIPTION hostnamectl may be used to query and change the system hostname and related settings.

dimasaburov
Dec 5, 2021

hostnamectl work only on systemd Linux systems, hostname work in all Linux systems.

jedrek
Apr 11, 2022

Both hostname and hostname can set the hostname so why ask for one command? How are users supposed to 'guess' what command they had in mind? Anyway, from manual pages: # man hostname When called with one argument or with the --file option, the commands set the host name or the NIS/YP domain name. hostname uses the sethostname(2) function, while all of the three domainname, ypdomainname and nisdomainname use setdomainname(2). Note, that this is effective only until the next reboot. Edit /etc/hostname for permanent change. # man hostnamectl set-hostname NAME Set the system hostname to NAME.

jedrek
Apr 11, 2022

hostnamectl, typoo in first sentence.

ccpmad
Apr 12, 2023

you can also use the hostname command to display the current hostname of the system. However, if you want to set the hostname, you should use hostnamectl on modern systems and hostname on older systems with the following syntax For modern systems: hostnamectl set-hostname new-hostname For older systems: hostname new-hostname note that in the original question, the command to set the hostname is requested, so in this case, the most appropriate command would be hostnamectl.

Rsantos123
May 19, 2024

The command is "hostname". Its required root permissions. hostname new-hostname

Robert12
Feb 10, 2022

Most of all Linux systems run on systemd , the answer is hostnamectl with the set-hostname option which will change the contents of the /etc/hostname file which defines the hostname of the machine.

drliu1202
Aug 3, 2022

"The /etc/hostname file can be edited directly, but the machine’s hostname can also be defined with the hostnamectl command. When supplied with sub-command set-hostname, command hostnamectl will take the name given as an argument and write it in /etc/hostname:" https://learning.lpi.org/en/learning-materials/102-500/109/109.2/109.2_01/#:~:text=The%20/etc/hostname%20file%20can%20be%20edited%20directly%2C%20but%20the%20machine%E2%80%99s%20hostname%20can%20also%20be%20defined%20with%20the%20hostnamectl%20command.%20When%20supplied%20with%20sub%2Dcommand%20set%2Dhostname%2C%20command%20hostnamectl%20will%20take%20the%20name%20given%20as%20an%20argument%20and%20write%20it%20in%20/etc/hostname%3A

marenco
Mar 21, 2022

the machine’s hostname can also be defined with the hostnamectl command. When supplied with sub-command set-hostname, command hostnamectl will take the name given as an argument and write it in /etc/hostname, so in this case the question is without parameters, will be HOSTNAME the answer

lucaverce
May 25, 2022

We can use the hostname command , but is not a permanent change, only 'til next reboot Man page for hostname: HOSTNAME(1) Linux Programmer's Manual HOSTNAME(1) NAME hostname - show or set the system's host name ... DESCRIPTION Hostname is used to display the system's DNS name, and to display or set its hostname or NIS domain name. ... >> Note, that this is effective only until the next reboot. >> Edit /etc/hostname for permanent change.

alextestwin
Nov 5, 2022

hostnamectl

klever
Jan 12, 2023

from the man page: hostnamectl may be used to query and change the system hostname and related settings.

karamazov
Mar 4, 2023

Who should listen to it, the community vote or what the system throws?

[Removed]
Jun 14, 2023

hostnamectl

Arielpetit
Jan 31, 2024

I Wrote the exam and i had 820/800

iagor_ml
Mar 6, 2024

The material says hostnamectl, but i tested on kali, apparently hostname name_to_set works