注册阿里云服务器后主机名称太长看着不舒服所以想改名
在网上找了好几种方法,大多就是更改/etc/network和/etc/hosts文件然后进行重启,试了几次都没有改过了
然后在博客https://blog.csdn.net/weixin_37282478/article/details/82965461,找到了很好的方法
hostnamectl set-hostname 'liangkk'
关于hostnamectl命令简单介绍
1、hostnamectl --help
hostnamectl [OPTIONS...] COMMAND ...
Query or change system hostname.
-h --help Show this help
--version Show package version
--no-ask-password Do not prompt for password
-H --host=[USER@]HOST Operate on remote host
-M --machine=CONTAINER Operate on local container
--transient Only set transient hostname
--static Only set static hostname
--pretty Only set pretty hostname
Commands:
status Show current hostname setti