Red Hat Enterprise Linux 7.2在安装的时候,会默认生成主机名:localhost. 那么如何修改成自己想要的自己名?

//格式为:用户名@主机名

比如: [root@localhost ~]#  修改成[root@xiaolyu ~]#

我的目前已经是[root@xiaolyu ~]# 主机名(hostname)为xiaolyu ,可以修改为lyu。

方法一: 用图像界面修改(永久性修改)

在终端输入命令 nutui :[root@xiaolyu ~]# nmtui

进入如下图形界面:

选择第三行:Set system hostname

按回车键,进入:

然后直接进行编辑修改即可:

选中《OK>按回车键即可。

OK 即可!

重新打开一个新的终端,既可以发现主机名已经修改过来了:

[root@lyu ~]#

方法二:用命令行模式修改主机名:(永久修改,静态模式)

比如这里讲lyu改成xiaolyu:

[root@lyu ~]# hostnamectl
Static hostname: lyu
Icon name: computer-vm
Chassis: vm
Machine ID: 41395788ce5a4b3f93805203ebf82245
Boot ID: 02c90c2e76784d1293358ab6bc509f78
Virtualization: vmware
Operating System: Red Hat Enterprise Linux Server 7.2 (Maipo)
CPE OS Name: cpe:/o:RedHat:enterprise_linux:7.2:GA:server
Kernel: Linux 3.10.0-327.el7.x86_64
Architecture: x86-64

[root@lyu ~]# hostname --help
Usage: hostname [-b] {hostname|-F file} set host name (from file)
hostname [-a|-A|-d|-f|-i|-I|-s|-y] display formatted name
hostname display host name

{yp,nis,}domainname {nisdomain|-F file} set NIS domain name (from file)
{yp,nis,}domainname display NIS domain name

dnsdomainname display dns domain name

hostname -V|--version|-h|--help print info and exit

Program name:
{yp,nis,}domainname=hostname -y
dnsdomainname=hostname -d

Program options:
-a, --alias alias names
-A, --all-fqdns all long host names (FQDNs)
-b, --boot set default hostname if none available
-d, --domain DNS domain name
-f, --fqdn, --long long host name (FQDN)
-F, --file read host name or NIS domain name from given file
-i, --ip-address addresses for the host name
-I, --all-ip-addresses all addresses for the host
-s, --short short host name
-y, --yp, --nis NIS/YP domain name

Description:
This command can get or set the host name or the NIS domain name. You can
also get the DNS domain or the FQDN (fully qualified domain name).
Unless you are using bind or NIS for host lookups you can change the
FQDN (Fully Qualified Domain Name) and the DNS domain name (which is
part of the FQDN) in the /etc/hosts file.

[root@lyu ~]# hostnamectl --static set-hostname xiaolyu

再次打开一个新终端,可以发现@后面的用户名已经修改。

[root@lyu ~]# hostname
xiaolyu
[root@lyu ~]# hostnamectl
Static hostname: xiaolyu
Icon name: computer-vm
Chassis: vm
Machine ID: 41395788ce5a4b3f93805203ebf82245
Boot ID: 02c90c2e76784d1293358ab6bc509f78
Virtualization: vmware
Operating System: Red Hat Enterprise Linux Server 7.2 (Maipo)
CPE OS Name: cpe:/o:redhat:enterprise_linux:7.2:GA:server
Kernel: Linux 3.10.0-327.el7.x86_64
Architecture: x86-64
[root@lyu ~]#

(init6或者reboot之后也可以,但是比较麻烦)。

而且是永久修改。

如何让@后面显示的主机名也跟着变呢?重启! reboot或者init 6

再次查看:

搞定!

Red Hat Enterprise Linux 7.2修改主机名(hostname)的更多相关文章

  1. Configure Always On Availability Group for SQL Server on RHEL——Red Hat Enterprise Linux上配置SQL Server Always On Availability Group

    下面简单介绍一下如何在Red Hat Enterprise Linux上一步一步创建一个SQL Server AG(Always On Availability Group),以及配置过程中遇到的坑的 ...

  2. Red Hat Enterprise Linux 7.x新特性

    Red Hat Enterprise Linux 7.x新特性 RHEL7新特性简介 1.      RHEL7目前支持架构 64-bit AMD.64-bit Intel.IBM POWER.IBM ...

  3. Red Hat Enterprise Linux 6.6安装体验

    Red Hat Enterprise Linux 6.6的安装首界面有五个选项,这跟以前的Red Hat Enterprise Linux 5.x的安装界面是有一些区别的.   安装或者升级现有系统( ...

  4. 如何安装win10+Red Hat Enterprise Linux双系统?

    1,如何安装win10+Red Hat Enterprise Linux双系统???? 有很多人(没做过调查,可能就我自己想装吧)想要安装Red Hat Enterprise Linux系统,但是又不 ...

  5. Red Hat Enterprise Linux 6.4常用命令

    常用命令: profile文件立即生效:source /etc/profile source /home/kituser/.bash_profile 修改文件夹子文件权限:chmod -R 777 / ...

  6. Deploy Oracle 10.2.0.5 DataGuard on Red Hat Enterprise Linux 6.4

    系统:Red Hat Enterprise Linux 6.4 数据库:Oracle 10.2.0.5.0 Patch Set 4 主机:10dg1 192.168.1.91 10dg2192.168 ...

  7. Red Hat Enterprise Linux Server(RHEL) yum安装软件时This system is not registered with RHN. RHN support will be disabled. 的解决方法(转)

    新安装了redhat6.5.安装后,登录系统,使用yum update 更新系统.提示: This system is not registered to Red Hat Subscription M ...

  8. Deploy Oracle 10.2.0.5 on Red Hat Enterprise Linux 6.4

    一.Linux系统安装和配置 1.安装系统时选Desktop 2.设置eth0网卡为静态IP,加入子网掩码,网关,DNS.并配置自己主动启动 3.改动/etc/hosts.加入主机名和相应IP 4.禁 ...

  9. 在Red Hat Enterprise Linux 7.3上安装SQL Server 2017

    必要条件: 1.在此快速安装过程中,您需要安装SQL Server 2017或SQL Server 2019上Red Hat Enterprise Linux (RHEL) 7.3 +.然后使用sql ...

随机推荐

  1. 【codeforces1058】Vasya and Golden Ticket 枚举+暴力+模拟

    #点击传送 题目描述 Recently Vasya found a golden ticket - a sequence which consists of nn digits a1a2-ana1a2 ...

  2. dva的effect那么难用,自己造一个轮子吧

    背景 对于dva这个开发框架,国内从事react的前端工程师多半不会感到陌生,dva完善的开发体系和简单的api,让其被广泛运用到实际工作中.我所在的公司也是长期使用dva作为基础的开发框架,虽然好用 ...

  3. 如何反编译Python写的exe到py

    参考链接: https://blog.csdn.net/qq_44198436/article/details/97314626?depth_1-utm_source=distribute.pc_re ...

  4. intouch制作历史趋势公用弹窗

    在先前项目中,历史趋势都是作为一个总体的画面,然后添加下拉菜单选择来配合使用.在新项目中,业主要求在相应的仪表上直接添加历史趋势,这就需要利用公用弹窗来制作历史趋势了. 1.窗体建立 窗体建立是比较简 ...

  5. php 获取上个月的起止时间戳

    $thismonth = date('m'); $thisyear = date('Y'); if ($thismonth == 1) { $lastmonth = 12; $lastyear = $ ...

  6. GhostScript 沙箱绕过(命令执行)漏洞(CVE-2019-6116)

    影响范围 Ghostscript 9.24之前版本 poc地址:https://github.com/vulhub/vulhub/blob/master/ghostscript/CVE-2019-61 ...

  7. 获取windows 操作系统下的硬件或操作系统信息等

    奇怪的工作,制作的是一款办公应用软件,领导却要求我统计用户计算机的物理信息,什么CPU的型号.核心数,什么内存信息等各种乱七八糟的用户信息.我想问,现在用户的信息就这么没有隐私性了么?想获取就获取传递 ...

  8. 超详细!Vue-Router手把手教程

    目录 1,router-view 2,router-link 3,重定向redirect 4,路由别名 5,路由传参props 5.1,布尔模式 5.2,对象模式 5.3,函数模式 6,路由守卫 6. ...

  9. .net 知新:【4】NuGet简介和使用

    在包管理以前我们在项目中引用第三方包通常是去下载dll放到项目中再引用,后来逐渐发展成各种包管理工具,nuget就是一种工具,适用于任何现代开发平台的基本工具可充当一种机制,通过这种机制,开发人员可以 ...

  10. 数据增广imgaug库的使用

    记录一下这两天用imgaug库做数据增广的代码,由于是算用算学的,所以只能把代码写出来,具体每种增广算法的原理和一些参数就不得而知了,不过我觉得也没必要把这么些个算法搜搞懂,毕竟重点是扩种数据.所以, ...