hostname
프로세스·시스템
쓰는 꼴
hostname [-f]이 기계의 이름을 찍거나 바꿉니다 — `hostname web01`은 재부팅까지만 버티니 오래 두려면 Linux는 `hostnamectl`, macOS는 `scutil --set HostName`이고, IP를 다 보는 `-I`는 Linux에만 있습니다.
자주 쓰는 옵션
| 옵션 | 뜻 |
|---|---|
| -s | Short name only, up to the first dot. |
| -f | Fully qualified domain name (Linux). |
| -I | All IP addresses of this host, space separated. Linux only, capital i. |
| -i | Resolve the host name; depends on /etc/hosts, so it often prints 127.0.1.1 (Linux). |
| hostname <newname> | Change it until the next reboot only. |
예시
hostname -fThe full name other machines see.
hostname -IEvery local IP without parsing ip or ifconfig output (Linux).
sudo hostnamectl set-hostname web01The permanent change on systemd; macOS uses scutil --set HostName.
무엇이 돌고 있고 무엇이 자원을 먹는지 봅니다. 죽이기 전에 무엇인지 확인하는 것이 순서입니다.
읽는 방법
- 대괄호 [ ]는 넣어도 되고 안 넣어도 되는 자리입니다.
- 점 셋 …은 여러 개를 이어 쓸 수 있다는 뜻입니다.
- 옵션은 대소문자를 가립니다 — -r과 -R이 다른 명령도 있습니다.
자주 묻는 것
Q. hostname은 무엇을 하나요?
이 기계의 이름을 찍거나 바꿉니다 — `hostname web01`은 재부팅까지만 버티니 오래 두려면 Linux는 `hostnamectl`, macOS는 `scutil --set HostName`이고, IP를 다 보는 `-I`는 Linux에만 있습니다.
Q. 어떻게 치나요?
hostname [-f] — 대괄호는 생략할 수 있는 자리입니다.
Q. 옵션은 몇 개나 자주 쓰나요?
여기 정리한 것은 5개입니다. 전체 목록은 man hostname에 있습니다. 이 명령은 프로세스·시스템 갈래입니다.
같이 보는 명령
man 페이지: man hostname