Linux view and set host name

Source: Internet
Author: User

1. Set host name     modify the hostname by editing the hostname field in the/etc/sysconfig/network file. :     [[email protected]/]# vim/etc/sysconfig/network      as shown below                                    networking=yes                                                                        networking_ipv6=yes                                                                  Hostname=zijuan                                                                       Hostname=zijuan indicates that the host is set to zijuan.      Note: After you modify the hostname, it takes effect after you restart the system.      2, view host name      [[email protected]/]# hostname                                                            zijuan                                                                                tip: Two simple commands temporarily set a hostname.      (1) Use the SYSCTL command to modify kernel parameters, format: SYSCTL kernel.hostname= hostname, as follows.      [[email protected]/]# sysctl kernel.hostname=newname                                     KERNEL.HOSTNAME=NEWNAME   &NBsp;        #newname为新设置的主机名   (2) Use the hostname command to set the host name. The format is: hostname host name, as follows.      [[email protected]/]# hostname newname     This setting is temporarily in effect. Setup fails after restarting the system.    

Use of the hostname command:

Hostname-s,--short Short host name-a,--alias alias Names-i,--ip-address Addresses for the host name-f,--fqdn,--long long host name (FQDN)-D,--domain DNS domain n Ame-y,--YP,--nis nis/yp domain name-f,--file read host name or NIS domain name from GI Ven file

Linux view and set host name

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: 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.