Skip to content

How to Change the Hostname on Linux

On Linux, you can change the hostname by using the hostnamectl command.

How to Set the Hostname on Linux

sudo hostnamectl set-hostname <new-hostname>
Code language: Bash (bash)

For example:

sudo hostnamectl set-hostname server1
Code language: JavaScript (javascript)

At this point, you will need to logout and back in to see the changes have taken effect.

See also  How to setup Certbot wildcard certificate on Apache
Tags:
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x