Centos 7更改Hostname

在把VPS上的系统升级到Centos 7之后,我尝试修改/etc/sysconfig/network来修改hostname, 但是没有用. 修改Centos 7的Hostname的方法和以前版本不同,希望本文能帮你来修改Hostname在Centos 7 / RHEL 7上.

使用hostnamectl来修改Hostname:

检查目前的Hostname

[root@vultr ~]# hostnamectl status
   Static hostname: vultr.guest
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 19a12d5f5d824794a19caf165a9b3bca
           Boot ID: 21c75ffe0718431d800fd8159be13d99
    Virtualization: kvm
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-123.20.1.el7.x86_64
      Architecture: x86_64

设置新的Hostname

[root@vultr ~]# hostnamectl set-hostname mysql.jzbk.org

检查当前Hostname

[root@vultr ~]# hostnamectl status
   Static hostname: mysql.jzbk.org
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 19a12d5f5d824794a19caf165a9b3bca
           Boot ID: 21c75ffe0718431d800fd8159be13d99
    Virtualization: kvm
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-123.20.1.el7.x86_64
      Architecture: x86_64

CentOS 下禁止运行screen 或建立新窗口时更改窗口尺寸

Xshell或Putty之类的连接到Centos下使用screen时会改变窗口的尺寸,非常烦人,可以通过如下方法修改使其不更改窗口尺寸。
编辑/etc/screenrc或~/.screenrc 加入下面的代码

# Change the xterm initialization string from is2=\E[!p\E[?3;4l\E[4l\E>
# (This fixes the "Aborted because of window size change" konsole symptoms found
#  in bug #134198)
termcapinfo xterm* 'is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l'