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