发表于: lnmp | 作者: | 日期: 2017/4/03 10:04
标签:

1.查看计算机名 hosname
【实例】

[root@Yuanji_Server ~]# hostname
Yuanji_Server


2.Centos 修改计算机名
———————
setep1.

hostname New-Server

setep2.
修改/etc/sysconfig/network

NETWORKING=yes
HOSTNAME=”New_Server” #将原来的进行修改
GATEWAY=”192.168.0.1″
GATEWAYDEV=”eth0″

setep3检查

sysctl kernel.hostname
New_Server

如果不是,就用

sysctl kernel.hostname=New-Server

setep4修改更新

/etc/hosts 中的内容

【实例】
[root@Yuanji_Server ~]# hostname 10-222
[root@Yuanji_Server ~]# hostname
10-222
NETWORKING=yes
HOSTNAME=10-222 #新的名字
GATEWAY=192.168.10.1
[root@Yuanji_Server ~]# sysctl kernel.hostname
kernel.hostname = 10-222
[root@Yuanji_Server ~]# more /etc/hosts
127.0.0.1 10-222
::1
断开ssh连接重新登录
[root@10-222 ~]#
服务器名字已改
3.Debian 修改计算名
————————
setep1.
/etc/hostname 修改这个文件
内容为
New-Server
setep2.
修改更新
/etc/hosts 中的内容
setep3 (不需要重启)
/etc/init.d/hostname.sh start
【实例】
root@3-Debain-Server:~# hostname
3-Debain-Server #查看现在的名字
修改/etc/hostname
root@3-Debain-Server:~# more /etc/hostname
Debain-Server #修改为新的名字
修改/etc/hosts
root@3-Debain-Server:~# cat /etc/hosts
127.0.0.1 localhost
127.0.0.1 Debain-Server #新的名字
/etc/init.d/hostname.sh start
断开ssh连接重新登录
root@Debain-Server
【注意】主机名的命名规范
=================================
有主机名只包含数字0-9,a-z(不分大小写),和-。其他的都是无效的字符串。
包括下划线_ 包括|,都是无效的。
常常会以为 _ (下划线) | (竖杠) 可以使用,其实是不可以的。使用无效的字符后,重启服务器,名字为
root(none):~#
hostname
(none)
===============================
以上是个人点点总结和理解,水平不高,文笔水平很烂,请各位大大见谅。
可以一起交流学习。
我的QQ:610851588
可以加入我建的群(现在群人很少,希望慢慢多起来)
Linux 群:183932302
Python ,shell 交流群:469094734
本文出自 “走起运维” 博客,转载请与作者联系!
来源:http://yuanji6699.blog.51cto.com/11568362/1773356

: https://blog.darkmi.com/2017/04/03/3921.html

本文相关评论 - 1条评论都没有呢
Post a comment now » 本文目前不可评论

No comments yet.

Sorry, the comment form is closed at this time.