hostname 명령어 (AIX 5.3·6.1)

핵심 정리

  • 현재 호스트 이름을 보여 줍니다. hostname -s는 도메인 부분을 뺀 짧은 이름을 보여 줍니다.
  • hostname 새이름으로 바꿀 수 있지만(root만) 실행 중인 시스템에만 적용되어 재부팅하면 돌아갑니다.
  • 영구로 바꾸려면 chdev -l inet0 -a hostname=새이름을 씁니다(실행 중인 이름도 함께 바뀜). 처음 TCP/IP를 구성할 때는 mktcpip이나 mkdev를 씁니다.
  • 호스트 이름을 바꾸면 /etc/hosts의 항목도 맞춰 고칩니다.
항목 내용
버전 AIX 5.3, AIX 6.1 (6.1 문서에 RBAC 보안 안내가 더해짐. 사용법은 같음)
원문 IBM Commands Reference — 5.3 Volume 2, 6.1 Volume 2
파일 /usr/bin/hostname
관련 명령어 chdev -l inet0 -a hostname=, mkdev, uname -n, mktcpip

목적

현재 호스트 시스템의 이름을 정하거나 보여 줍니다.

영어 원문

Sets or displays the name of the current host system.

구문

text
/usr/bin/hostname [ HostName ] [ -s ]

설명

/usr/bin/hostname 명령은 현재 호스트 시스템의 이름을 보여 줍니다. 호스트 이름은 root 권한이 있는 사용자만 정할 수 있습니다. mkdev와 chdev 명령도 호스트 이름을 영구로 정합니다. TCP/IP 인스턴스를 처음 정의할 때는 mkdev를 씁니다.

Web-based System Manager(wsm)의 System 응용 프로그램이나 SMIT 빠른 경로 smit mkhostname으로도 이 명령을 실행할 수 있습니다.

영어 원문

The /usr/bin/hostname command displays the name of the current host system. Only users with root user authority can set the host name. The mkdev command and the chdev commands also set the host name permanently. Use the mkdev command when you are defining the TCP/IP instance for the first time.

You can use the System application in Web-based System Manager (wsm) to change system characteristics. You could also use the System Management Interface Tool (SMIT) smit mkhostname fast path to run this command.

플래그

플래그 설명
-s 출력하는 이름에서 도메인 정보를 잘라 냅니다.
영어 원문
  • -s — Trims any domain information from the printed name.

매개변수

매개변수 설명
HostName 호스트의 주 이름을 정합니다. root 권한이 있어야 씁니다.

쓰는 예(원문에는 예 절이 없음):

bash
hostname                              # 지금 이름(FQDN일 수 있음)
hostname -s                           # 도메인을 뺀 짧은 이름
hostname aixhost02                    # 실행 중인 이름만 바꿈(재부팅하면 돌아감)
chdev -l inet0 -a hostname=aixhost02  # 영구로 바꿈(ODM)
lsattr -El inet0 -a hostname          # ODM에 있는 이름
영어 원문
  • HostName — Sets the primary name of the host.
  • Note: You must have root user authority to use the HostName parameter.

보안

RBAC 사용자와 Trusted AIX 사용자는 주의하세요. 이 명령은 특권 작업을 할 수 있으며, 특권 작업은 특권 사용자만 할 수 있습니다. 특권과 권한 목록은 lssecattr 명령이나 getcmdattr 하위 명령으로 봅니다(6.1 문서에만 있음).

영어 원문

Attention RBAC users and Trusted AIX users: This command can perform privileged operations. Only privileged users can run privileged operations. For more information about authorizations and privileges, see Privileged Command Database in Security. For a list of privileges and the authorizations associated with this command, see the lssecattr command or the getcmdattr subcommand.

Related information:

  • chdev command
  • mkdev command
  • gethostname command
  • TCP/IP name resolution

리눅스(GNU)와 다른 점

리눅스에서도 hostname으로 보고 임시로 바꿉니다. 영구로 바꾸려면 systemd 환경에서 hostnamectl set-hostname 새이름을 쓰며, 이 명령이 /etc/hostname을 고칩니다. hostname -s(짧은 이름)는 같고, 리눅스에는 -f(FQDN), -I(모든 IP) 같은 옵션도 있습니다.