Change Linux host name permanently through command line

Change Linux host name permanently through command line

If you are trying to change Linux host name permanently through command line using shell terminal and its not changing using host name command, I am sure  this will definitely help you to solve your problem.

Someone asked me when I am trying to change my Linux based server, desktop host name (Computer Name) using host name command it’s changing but after restarting machine it’s again changed to old name. So I decided to write this post.

Here we can see simple steps to permanently change host name (Computer Name) of your Linux server desktop which will not be change after restarting.   


Steps to change host name :-
Use any one of your favorite available editor such as vi, vim, gedit, nano, pico  and open
vi /etc/sysctl.conf file.

And add the following lines in sysctl.conf.
kernel.hostname = techitadmin  (your desire host name)
kernel.domainname = techitadmin.com (your domain name)
After adding the above entry run this command

# sysctl -p /etc/sysctl.conf
Problem solved,
Now just type “hostname” and press enter.  
# hostname command will show now new changed host name.  


Previous Post
Next Post
Related Posts

0 Comments: