最近CentOS7で~ctlコマンドを使い始めました。使用方法に手間取ったのでメモする。
man(1),Tabキー,--helpの有用性に気づかされました。
今後も追記予定
調べたコマンド一覧
hostdatectl--ホスト名関連
timedatectl--システム時刻関連
実行環境
OS:CentOS Linux release 7.1.1503 (Core)
HW:VMware Workstation 12 Player
hostnamectl
ホスト名の確認
[root@localhost ~]# hostnamectl status
Static hostname: localhost.localdomain
Icon name: computer-vm
Chassis: vm
Machine ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Boot ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Virtualization: vmware
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-229.11.1.el7.x86_64
Architecture: x86_64
ホスト名を変更
[root@localhost ~]# hostnamectl set-hostname TestServer
確認手順1
[root@localhost ~]# hostnamectl status
Static hostname: testserver
Pretty hostname: TestServer
Icon name: computer-vm
Chassis: vm
Machine ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Boot ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Virtualization: vmware
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-229.11.1.el7.x86_64
Architecture: x86_64
確認手順2
[root@localhost ~]# cat /etc/hostname
testserver
リブートすればroot@testserver
・用語
Static hostname--システム管理者が付けた静的なホスト名
Pretty hostname--不明..ご存知の方がいればご教示くださると助かります。
Transient hostname --DHCP又はDNSで割り当てられたホスト名
timedatectl
・現在のシステム時刻の確認
[root@testserver ~]# timedatectl
Local time: 木 2015-09-24 21:54:27 JST
Universal time: 木 2015-09-24 12:54:27 UTC
RTC time: 木 2015-09-24 12:54:27
Timezone: Asia/Tokyo (JST, +0900)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a
・利用可能なタイムゾーンの確認
[root@testserver ~]# timedatectl list-timezones
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Bamako
Africa/Bangui
Africa/Banjul
・・・・
・タイムゾーンの変更
[root@testserver ~]# timedatectl set-timezone Africa/Malabo
[root@testserver ~]# timedatectl
Local time: 木 2015-09-24 13:53:57 WAT
Universal time: 木 2015-09-24 12:53:57 UTC
RTC time: 木 2015-09-24 12:53:56
Timezone: Africa/Malabo (WAT, +0100)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a
・現在の時刻と日付の設定変更
[root@testserver ~]# timedatectl set-time 6:00:00
[root@testserver ~]# timedatectl
Local time: 木 2015-09-24 06:00:02 JST
Universal time: 水 2015-09-23 21:00:02 UTC
RTC time: 水 2015-09-23 21:00:02
Timezone: Asia/Tokyo (JST, +0900)
NTP enabled: yes
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
最後に
今後は以下も追記予定
systemctl--サービス関連
nmcli--ネットワーク・デバイス関連
journalctl--ログ関連