View and modify the machine name in Linux

Source: Internet
Author: User

View and modify the machine name in Linux

We often need to copy virtual machines in VMWare. For new machines to be copied, we need to modify the machine name. Otherwise, there will be conflicts in the same LAN, the following describes how to view and modify the machine name in Linux:

1. view the machine name of the system:

Log on as the root user and enter hostname in the terminal console.

[Root @ bkjia] # hostname

Bkjia

2. Temporarily modify the machine Name:

[Root @ bkjia] # hostname yourname

[Root @ bkjia] # hostname

Yourname

Note: However, the modification in step 1 can only be temporarily valid, and the machine is restarted and restored. To make the modification take effect permanently, continue with the following steps:

3. Modify the hosts file (Path:/etc/hosts ):

[Root @ bkjia] # vi/etc/hosts

Change all original hosts names to the ones you want to change. In addition, note that the ip address in the hosts file must be changed to the current ip address of the system (ip address query method: # ifconfig)

4. Modify the network file (Path:/etc/sysconfig/network ):

[Root @ bkjia] # vi/etc/sysconfig/network

Replace XXX in hostname = XXX with the name you want to change.

5. Restart the machine:

[Root @ bkjia] # reboot

OK. The modification is complete ~~~~~~~~

This article permanently updates the link address:

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.