1.临时修改主机名
zhh64
zhouhh@zzhh64:~$ hostname
zzofs
/[/e]0;/u@/h: /w/a/]${debian_chroot:+($debian_chroot)}/u@/h:/w/$
@符号后面跟/h即主机名。
2.永久修改主机名
NETWORKING=yes
HOSTNAME=localhost.localdomain
GATEWAY=192.168.10.1
NETWORKING_IPV6=no
HOSTNAME=gdbk
::1 hdirect30 hdirect30
localhost.localdomain
zhh64
3. 其他修改方式
kernel.hostname = zhh64
kernel.hostname = zzh
4. hosts文件与主机名修改无关
192.168.11.116 zhh64
192.168.12.14 centdev
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
PING zhh64 (192.168.11.116) 56(84) bytes of data.
64 bytes from zhh64 (192.168.11.116): icmp_seq=1 ttl=64 time=0.077 ms
PING centdev (192.168.12.14) 56(84) bytes of data.
64 bytes from centdev (192.168.12.14): icmp_seq=1 ttl=63 time=0.726 ms
zhouhh@centdev's password:
Last login: Wed Feb 3 10:03:09 2010 from 192.168.11.116
[zhouhh@centdev ~]$
[zhouhh@centdev ~]$ ifconfig eth0 | grep inet
inet addr:192.168.12.14 Bcast:192.168.12.255 Mask:255.255.255.0
inet6 addr: fe80::21e:c9ff:fe57:2575/64 Scope:Link