CentOS Linux 5/6 Change Hostname Command - VPS - Cloud Server Linux - บอร์ด ชุมชนคนทำเว็บ
บอร์ด ชุมชนคนทำเว็บ

CentOS Linux 5/6 Change Hostname Command

Administrator

  • www.nakhonitech.com
  • *****
  • 102
  • +0/-0
    • ดูรายละเอียด
    • โฮสติ้งนครไอเทค โฮสติ้งราคาถูก
CentOS Linux 5/6 Change Hostname Command
« เมื่อ: 20 มี.ค. 2016 »
อ้างถึง
am a new CentOS Linux server user. How do I change hostname on CentOS Linux? How can I change server hostname on CentOS Linux version 5 or 6?

You need to use the following commands to set or view current hostname, domain name and/or FQDN (Fully Qualified Domain Name):
1.dnsdomainname command : Display the system’s DNS domain name.
2.hostname command : Show or set the system’s host name.
You also need to edit the following files for a hostname change:

1. /etc/sysconfig/network file.
2. /etc/hosts file.

In this tutorial, I will show you how to set/change a server hostname in CentOS Linux to “server1.cyberciti.biz”. CentOS / RHEL version 7.x users, see this page for more info.

Display current hostname

Type the following command:

โค๊ด: [Select]
# hostname
Sample outputs:
โค๊ด: [Select]
server1
To display current domain name:
Type the following command:

โค๊ด: [Select]
# dnsdomainname
Sample outputs:

โค๊ด: [Select]
domain.com

Hostname change procedure on CentOS


Open the terminal or login to the remote server using ssh client. Edit
/etc/sysconfig/network file, enter:

โค๊ด: [Select]
# vi /etc/sysconfig/network
Find and modify HOSTNAME value to set to FADN such as server1.domain.com:

โค๊ด: [Select]
HOSTNAME="server1.domain.com"
Save and close the file.

Edit hosts file
Edit /etc/hosts file, enter:

โค๊ด: [Select]
# vi /etc/hosts
You need to set or change the host that is set to your IP address on server.

โค๊ด: [Select]
127.0.0.1 localhost
10.240.40.209 server1.cyberciti.biz server1  # Added by nixCraft

Save and close the file.

Set hostname manually without rebooting the box

Type the following command:

โค๊ด: [Select]
# hostname server1.domain.com
Restart the CentOS networking and other services (if any)
You need to restart the networking service on CentOS Linux, enter:

โค๊ด: [Select]
# service network restart
OR

โค๊ด: [Select]
# /etc/init.d/network restart
Verify new hostnames
Simply type the following commands:

โค๊ด: [Select]
# hostname
# dnsdomainname
โฮสติ้งถูก นครไอเทค ฟรีโฮสติ้ง โฮสติ้งราคาถูก hostingราคาถูก vps วิทยุออนไลน์ ตัวแทนจำหน่าย Reseller Hosting
https://www.nakhonitech.com/