Five questions about modifying hostname under Linux (ii)

Source: Internet
Author: User

Issue 2: After modifying the hostname, how to make it effective immediately without restarting the operating system.

Method 1: After you modify the hostname under/etc/sysconfig/network, then use echo servername >/proc/sys/kernel/hostname.

[Email protected] ~]# echo Test >/proc/sys/kernel/hostname

Note that the current session still does not change, but subsequent new sessions will take effect.

Method 2: After modifying the hostname under/etc/sysconfig/network, then use the Sysctl kernel.hostname command to make it effective immediately

[Email protected] ~]# sysctl Kernel.hostname=test2

Kernel.hostname = Test2

Note that the current session still does not change, but subsequent new sessions take effect.

Method 3: After modifying the hostname under/etc/sysconfig/network, then use the hostname command to make it effective

[Root@test ~]# hostname db-server

Note that the current session still does not change, but subsequent new sessions take effect.

In fact, these methods are only combined with permanent modification and temporary modification of hostname, so that it does not have to restart the Linux server, haha, do not know you understand.


If you want to dive into the Linux system novice, you can also download a German Linux software center trial.
Free: Http://www.nfs-cloud.cn:81/appCenter/open/softcenter

Five questions about modifying hostname under Linux (ii)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.