리눅스 7.x 이상 부터 hostname 변경시 hostnamectl 명령어로 hostname를 쉽게 변경 할 수 있습니다.
[root@localhost ~]# hostname
localhost.localdomain --> 기본적으로 현재 사용 중인 이름
[root@localhost ~]#
[root@localhost]# hostnamectl set-hostname SLASM19C
[root@localhost]# hostname
slasm19c --> 소문자로 변경 되었네요.
[root@localhost]#
[root@localhost]# 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 settings
set-hostname NAME Set system hostname
set-icon-name NAME Set icon name for host
set-chassis NAME Set chassis type for host
set-deployment NAME Set deployment environment for host
set-location NAME Set location for host
[root@localhost]#
[root@localhost ~]# hostnamectl set-hostname SLASM19C --static
[root@localhost ~]# hostname
SLASM19C --> 대문자로 변경
[root@localhost ~]#
[root@localhost ~]# reboot
[root@SLASM19C ~]# hostname
SLASM19C
[root@SLASM19C ~]#
[root@SLASM19C etc]# more /etc/hostname
SLASM19C
[root@SLASM19C etc]#
[root@SLASM19C etc]# hostnamectl set-hostname SLasm9c --static
[root@SLASM19C etc]# hostname
SLasm9c --> 대소문자 변경
[root@SLASM19C etc]#
[root@SLASM19C etc]# hostnamectl
Static hostname: SLasm9c
Icon name: computer-vm
Chassis: vm
Machine ID: 3f62be271cd1354d98aedb0211e7bffa
Boot ID: fa751d2126f441a29c000abcef1ba4c3
Virtualization: kvm
Operating System: Red Hat Enterprise Linux Server 7.7 (Maipo)
CPE OS Name: cpe:/o:redhat:enterprise_linux:7.7:GA:server
Kernel: Linux 3.10.0-1062.el7.x86_64
Architecture: x86-64
[root@SLASM19C etc]
[root@server-150 ~]# hostnamectl
Static hostname: server-150
Icon name: computer-vm
Chassis: vm
Machine ID: 36cc986e11e540708dbf81d00c454c56
Boot ID: 81d0fc11950a4842b3693b9122cda935
Virtualization: kvm
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@server-150 ~]#
이런 명령어도 있었군요...
좋아요... ㅎㅎ