Step 1:
# Su-root (or log on as the root user)
Otherwise, the hostname cannot be modified.
We can view the name of the current hostname:
[Root @ vm1035 ~] # Hostname
Vm1035
[Root @ vm1035 ~] #
Then we change vm1035 to vm3012.
Step 2:
# Vi/etc/hosts
Change the vm1035 output in/etc/hosts to vm3012, for example:
# Do not remove the following line, or various programs
# That require network functionality will fail.
127.0.0.1 melvrhel5tmp localhost. localdomain localhost
: 1 localhost6.localdomain6 localhost6
10.30.149.35 vm3012.autotest. corp vm3012
Step 3:
# Vi/etc/sysconfig/network
Change the hostname to vm3012 as follows:
NETWORKING = yes
NETWORKING_IPV6 = yes
HOSTNAME = vm3012
Step 4:
# Hostname vm3012
Use the command to specify the hostname.
Step 5:
Once you log on again, the command prompt character will change:
[Root @ vm3012 ~] #
It indicates that the hostname is successfully modified. ^_^