How to Change hostname in Linux?

One of many important duties for a system administrator is figuring out tips on how to change the host title.

Should you entered the fallacious hostname throughout set up otherwise you wish to change it, you possibly can change it as under. The next has been examined on Ubuntu and CentOS.

Altering the hostname entails three steps.

  • Change HOSTNAME worth /and so forth/sysconfig/community
  • Change the hostname to /and so forth/hosts
  • Replace hostname on the terminal

1. Show the host title

Let’s discover out the configured title by operating hostname on the terminal.

[root@centos-s-1vcpu-2gb-lon1-01 ~]# hostname
centos-s-1vcpu-2gb-lon1-01
[root@centos-s-1vcpu-2gb-lon1-01 ~]#

Let’s change to geekflare

2. Change the host title

Edit /and so forth/sysconfig/community use file vito look HOSTNAME= and replace that to the specified title.

Comment: I seen on a Cloud VM that the HOSTNAME entry doesn’t exist. Should you do not discover it in your server, you possibly can ignore this step.

Earlier than change:

# cat community
NETWORKING=sure
NETWORKING_IPV6=no
HOSTNAME=centos-s-1vcpu-2gb-lon1-01

After change:

# cat community
NETWORKING=sure
NETWORKING_IPV6=no
HOSTNAME=geekflare
[root@localhost sysconfig]#

The following step would change the hostname in a hosts file.

Edit /and so forth/hosts file, seek for the present hostname in 127.0.0.1 and server IPs (if any) and replace these to those you configured above.

Earlier than change:

[root@centos-s-1vcpu-2gb-lon1-01 ~]# cat /and so forth/hosts | grep -v '^#'
127.0.0.1 centos-s-1vcpu-2gb-lon1-01 centos-s-1vcpu-2gb-lon1-01
127.0.0.1 localhost.localdomain localhost
127.0.0.1 localhost4.localdomain4 localhost4

::1 centos-s-1vcpu-2gb-lon1-01 centos-s-1vcpu-2gb-lon1-01
::1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6

[root@centos-s-1vcpu-2gb-lon1-01 ~]#

After change:

[root@centos-s-1vcpu-2gb-lon1-01 ~]# cat /and so forth/hosts | grep -v '^#'
127.0.0.1 geekflare
127.0.0.1 localhost.localdomain localhost
127.0.0.1 localhost4.localdomain4 localhost4

::1 centos-s-1vcpu-2gb-lon1-01 centos-s-1vcpu-2gb-lon1-01
::1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6

[root@centos-s-1vcpu-2gb-lon1-01 ~]#

3. Change the hostname on the terminal

And at last you enter the hostname command with the specified worth.

[root@centos-s-1vcpu-2gb-lon1-01 ~]# hostname geekflare

Attempt logging into your server once more and you’ll discover the brand new hostname.

Utilizing DigitalOcean Server?

If you wish to change the hostname on the DigitalOcean VM, you could additionally replace the hostname in /and so forth/hostname file.

Here is a brief video demonstration.

That was straightforward.

Is it not? Need to be taught extra about Linux? Then view this administration course.

Rate this post
porno izle altyazılı porno porno