Linux--hostname配置

来源:互联网 发布:商品期货软件 编辑:程序博客网 时间:2024/06/05 09:50
1.查看
[root@prod ~]# hostname
prod.localdomain
[root@prod ~]# more /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=prod.localdomain


2.修改/etc/hosts 和 /etc/sysconfig/network(--需要重启生效,永久性修改)
[root@prod ~]# vi /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1        localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6
192.168.1.131   testdb.localdomain testdb


[root@prod ~]# vi /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=testdb.localdomain


3.使其配置生效(--运行后立即生效(新会话生效),但是在系统重启后会丢失所做的修改)
[root@prod ~]# sysctl kernel.hostname=testdb
kernel.hostname = testdb
或者 
[root@prod ~]# hostname testdb
0 0