Exam 102-500 All QuestionsBrowse all questions from this 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.)

    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
lucaverce

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

ngotru97

How change with "systemctl" bro

MaikyCR28

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

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

you're right

k3n_

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

Rini_Giannenzo

Anche hostnamectl lo fa [con meno sethostname

lucaverce

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.

isaac_paul

hostname is the correct answer

drliu1202

"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.

Rsantos123

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

ccpmad

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.

jedrek

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

hostnamectl, typoo in first sentence.

dimasaburov

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

iagor_ml

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

Arielpetit

I Wrote the exam and i had 820/800

[Removed]

hostnamectl

karamazov

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

klever

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

alextestwin

hostnamectl

lucaverce

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.

marenco

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

Robert12

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

"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