zoukankan      html  css  js  c++  java
  • CentOS7设置host name

    CentOS7设置host name

    环境说明:

    • 内核版本:3.10.0-1062.9.1.el7.x86_64

    本文先使用命令方式将主机名修改为“localhost”,再使用修改文件的方式将主机名修改为“jarvis”,以此演示主机名的修改。

    查看hostname

    • 方法一:‘hostname’命令

      [root@jarvis ~]# hostname
      jarvis
      
    • 方法二:‘hostnamectl’命令

      [root@jarvis ~]# hostnamectl
         Static hostname: jarvis
         Pretty hostname: Jarvis
               Icon name: computer-vm
                 Chassis: vm
              Machine ID: bb303a4a8b1846ce9ac8531e1b67db9b
                 Boot ID: 81745e108ae64db18eea055db0702bf6
          Virtualization: kvm
        Operating System: CentOS Linux 7 (Core)
             CPE OS Name: cpe:/o:centos:centos:7
                  Kernel: Linux 3.10.0-1062.9.1.el7.x86_64
            Architecture: x86-64
      

    设置hostname

    • 使用命令设置

      hostnamectl set-hostname “主机名”

      [root@jarvis ~]# hostnamectl set-hostname localhost
      [root@jarvis ~]# hostname
      localhost
      [root@jarvis ~]# hostnamectl
         Static hostname: localhost
               Icon name: computer-vm
                 Chassis: vm
              Machine ID: bb303a4a8b1846ce9ac8531e1b67db9b
                 Boot ID: 81745e108ae64db18eea055db0702bf6
          Virtualization: kvm
        Operating System: CentOS Linux 7 (Core)
             CPE OS Name: cpe:/o:centos:centos:7
                  Kernel: Linux 3.10.0-1062.9.1.el7.x86_64
            Architecture: x86-64
      
    • 通过修改配置文件设置

      [root@jarvis ~]# vim /etc/hostname	//打开此文件,将其中内容修改为“jarvis”
      [root@jarvis ~]# reboot		//修改文件的方式一定要自启
      [root@jarvis ~]# hostname
      jarvis
      

    日拱一卒,功不唐捐!

    日拱一卒,功不唐捐!
  • 相关阅读:
    多屏共享
    md5-linux_shell
    2017年会所得
    linux无线网络配置_转
    (转)台式机华硕主板双显卡切换,怎么舒服怎么来
    Apache FtpServer 实现文件的上传和下载
    (转载)Windows 上搭建Apache FtpServer
    Eclipse常用设置
    博客园文章样式修改
    黑马公社学习
  • 原文地址:https://www.cnblogs.com/mychangee/p/12439791.html
Copyright © 2011-2022 走看看