[note1@localhost]$ sudo vi /etc/sysconfig/network
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for note1:#在这里输入密码
#Created by anaconda
HOSTNAME=note(添加这一行)
#添加上面的这行文字然后按ctrl+c,输入":wq"按enter建退出
~
~
~
"/etc/hosts" 5L, 221C written
[note1@localhost]$su - root (获取root权限)
Password: (输入root的密码)
Last login: Wed Sep 26 07:14:35 ADT 2018 on pts/0
[root@localhost~]# hostname note(执行)
[root@localhost~]# su - note1
Last login: Wed Sep 26 07:15:37 ADT 2018 on pts/0
[note1@note~]$
2. 修改ip地址与主机名映射
[note1@note ~]$ sudo vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.16.100 note1(添加这一行,当然你也可以添加多台主机名的映射)
~
~
"/etc/hosts" 3L, 179C written
[note1@note ~]$ ping note1(最后ping就能ping到了)
PING note1 (192.168.16.100) 56(84) bytes of data.
64 bytes from note1 (192.168.16.100): icmp_seq=1 ttl=64 time=0.090 ms
64 bytes from note1 (192.168.16.100): icmp_seq=2 ttl=64 time=0.035 ms
64 bytes from note1 (192.168.16.100): icmp_seq=3 ttl=64 time=0.035 ms
64 bytes from note1 (192.168.16.100): icmp_seq=4 ttl=64 time=0.035 ms
64 bytes from note1 (192.168.16.100): icmp_seq=5 ttl=64 time=0.069 ms
64 bytes from note1 (192.168.16.100): icmp_seq=6 ttl=64 time=0.036 ms
64 bytes from note1 (192.168.16.100): icmp_seq=7 ttl=64 time=0.058 ms