原创作品,出自 “深蓝的blog” 博客,欢迎转载,转载时请务必注明以下出处,否则追究版权法律责任。
深蓝的blog:http://blog.csdn.net/huangyanlong/article/details/45476569
方式一:临时修改主机名
语法:
#hostname <主机名>
例:
[[email protected] /]# hostname hyltest [[email protected] /]# su - Last login: Sun May 3 17:58:30 CST 2015 on pts/1 [[email protected] ~]#
方式二:命令修改主机名
语法:
#hostnamectl set-hostname <主机名>
查看hostnamectl命令帮助
[[email protected] ~]# hostnamectl -help
hostnamectl [OPTIONS...] COMMAND ...
Query or change system hostname.
-h --help Show this help
--version Show package version
--transient Only set transient hostname
--static Only set static hostname
--pretty Only set pretty hostname
-P --privileged Acquire privileges before execution
--no-ask-password Do not prompt for password
-H --host=[[email protected]]HOST Operate on remote host
Commands:
status Show current hostname settings
set-hostname NAME Set system hostname
set-icon-name NAME Set icon name for host
set-chassis NAME Set chassis type for host
例:
[[email protected] ~]# hostnamectl set-hostname hyldb [[email protected] ~]# su - Last login: Sun May 3 18:02:11 CST 2015 on pts/1 [[email protected] ~]#
方式三:配置文件手工修改主机名
语法:
修改hostname配置文件
例:
[[email protected] ~]# cd /etc [[email protected] etc]# vi hostname hyldb ~ [[email protected] etc]# su - Last login: Sun May 3 18:03:15 CST 2015 on pts/1 [[email protected] ~]#
小结:
hostnamectl -help
/etc/hostname
原创作品,出自 “深蓝的blog” 博客,欢迎转载,转载时请务必注明以下出处,否则追究版权法律责任。
深蓝的blog:http://blog.csdn.net/huangyanlong/article/details/45476569