change hostname -systemd

       root 

 post 

 manpage 

 external links 

 about me 
  After systemd came into the picture of Linux
managing the machine and it's services became more easier.
Also due to this in every Linux distro it's commands
are much similar to manage the machine and it's services.

To apply the changes in hostname first need to be super user that is root.
As this is a system change so prvilege of super user is require.
Below is the command to become root user
$ su -

Or
$ sudo -i


To change the hostname use the below command of systemd.
# hostnamectl set-hostname [desire hostname]

For example:
# hostnamectl set-hostname linuxmachine


Or you may use sudo tool with above command as shown in below example.
Below one line command can also be useful in bash scripting.
$ sudo hostnamectl set-hostname [desire hostname]

For example:
$ sudo hostnamectl set-hostname linuxmachine


Use below command to verify the hostname changed sucessfully in systemd.
$ hostname

There is no require to reboot the machine to apply changes done in hostname.
To get the effect of the change in hostname, user need to login again.

  systemd: /usr/bin/hostnamectl




Designed by SanjuD(@ngineerbabu)