RHEL7(CentOS7)の新コマンド
2014年6月にRHEL7が登場し、7.1がリリースされてからもう半年が過ぎます。
今まで利用に迫られないことから書籍を読むに留めていたのですが、そろそろ時期的にも
必要になってくることと、少し時間ができたので新アーキテクチャのコマンドをざざっと列挙してみようかと。
今更感ありますが、自分のメモとして残しておくことにします。
環境はAzure上でCentOS Linux release 7.1.1503 (Core)にて動かしています。
サービス系(systemctl)
サービスの起動
$ systemctl start httpd
サービスの停止
$ systemctl stop httpd
状態確認
$ systemctl status httpd 【停止時】 httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled) Active: inactive (dead) Oct 05 07:19:17 centos7 systemd[1]: Starting The Apache HTTP Server... Oct 05 07:19:17 centos7 httpd[2425]: AH00558: httpd: Could not reliably det...ge Oct 05 07:19:18 centos7 systemd[1]: Started The Apache HTTP Server. Oct 05 07:22:31 centos7 systemd[1]: Started The Apache HTTP Server. Oct 05 07:23:20 centos7 systemd[1]: Started The Apache HTTP Server. Oct 05 07:23:34 centos7 systemd[1]: Stopping The Apache HTTP Server... Oct 05 07:23:35 centos7 systemd[1]: Stopped The Apache HTTP Server. Hint: Some lines were ellipsized, use -l to show in full. 【起動時】 httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled) Active: active (running) since Mon 2015-10-05 07:24:12 UTC; 6s ago Main PID: 2445 (httpd) Status: "Processing requests..." CGroup: /system.slice/httpd.service tq2445 /usr/sbin/httpd -DFOREGROUND tq2446 /usr/sbin/httpd -DFOREGROUND tq2447 /usr/sbin/httpd -DFOREGROUND tq2448 /usr/sbin/httpd -DFOREGROUND tq2449 /usr/sbin/httpd -DFOREGROUND mq2450 /usr/sbin/httpd -DFOREGROUND Oct 05 07:24:11 centos7 systemd[1]: Starting The Apache HTTP Server... Oct 05 07:24:12 centos7 httpd[2445]: AH00558: httpd: Could not reliably det...ge Oct 05 07:24:12 centos7 systemd[1]: Started The Apache HTTP Server. Hint: Some lines were ellipsized, use -l to show in full.
サービスの再起動
$ systemctl restart httpd
設定反映
$ systemctl reload httpd
自動起動の有効
$ systemctl enable httpd ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service'
強制終了
- sオプション付けなければ TREM (15)で終了します。
$ systemctl kill -s 9 httpd $ systemctl status httpd httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled) Active: failed (Result: exit-code) since Mon 2015-10-05 07:26:40 UTC; 13s ago Process: 2498 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE) Main PID: 2459 (code=killed, signal=KILL) Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec" Oct 05 07:24:44 centos7 systemd[1]: Starting The Apache HTTP Server... Oct 05 07:24:44 centos7 httpd[2459]: AH00558: httpd: Could not reliably det...ge Oct 05 07:24:44 centos7 systemd[1]: Started The Apache HTTP Server. Oct 05 07:24:49 centos7 systemd[1]: Reloading The Apache HTTP Server. Oct 05 07:24:49 centos7 httpd[2467]: AH00558: httpd: Could not reliably det...ge Oct 05 07:24:49 centos7 systemd[1]: Reloaded The Apache HTTP Server. Oct 05 07:26:39 centos7 systemd[1]: httpd.service: main process exited, cod...LL Oct 05 07:26:40 centos7 kill[2498]: kill: cannot find process "" Oct 05 07:26:40 centos7 systemd[1]: httpd.service: control process exited, ...=1 Oct 05 07:26:40 centos7 systemd[1]: Unit httpd.service entered failed state. Hint: Some lines were ellipsized, use -l to show in full.
ログ確認系(journalctl)
サービスログの確認
$ journalctl -u httpd -- Logs begin at Mon 2015-10-05 06:41:58 UTC, end at Mon 2015-10-05 08:06:20 UTC Oct 05 07:19:17 centos7 systemd[1]: Starting The Apache HTTP Server... Oct 05 07:19:17 centos7 httpd[2425]: AH00558: httpd: Could not reliably determin Oct 05 07:19:18 centos7 systemd[1]: Started The Apache HTTP Server. Oct 05 07:22:31 centos7 systemd[1]: Started The Apache HTTP Server. Oct 05 07:23:20 centos7 systemd[1]: Started The Apache HTTP Server. Oct 05 07:23:34 centos7 systemd[1]: Stopping The Apache HTTP Server... Oct 05 07:23:35 centos7 systemd[1]: Stopped The Apache HTTP Server. Oct 05 07:24:11 centos7 systemd[1]: Starting The Apache HTTP Server... Oct 05 07:24:12 centos7 httpd[2445]: AH00558: httpd: Could not reliably determin Oct 05 07:24:12 centos7 systemd[1]: Started The Apache HTTP Server.
末尾を最新状態で出力し続ける(tail -f)
$ journalctl -f httpd -- Logs begin at Mon 2015-10-05 06:41:58 UTC. -- Oct 05 07:32:39 centos7 systemd[1]: httpd.service: control process exited, ...=1 Oct 05 07:32:39 centos7 systemd[1]: Unit httpd.service entered failed state. Oct 05 07:32:56 centos7 systemd[1]: Starting The Apache HTTP Server... Oct 05 07:32:56 centos7 httpd[11182]: AH00558: httpd: Could not reliably de...ge Oct 05 07:32:56 centos7 systemd[1]: Started The Apache HTTP Server. Oct 05 07:33:05 centos7 systemd[1]: Stopping The Apache HTTP Server..
末尾から件数を指定して表示する(以下は10件)
$ journalctl -n 10 -- Logs begin at Mon 2015-10-05 06:41:58 UTC, end at Mon 2015-10-05 08:08:01 UTC Oct 05 08:06:13 centos7 systemd[1]: Starting Session 5 of user azureuser. Oct 05 08:06:13 centos7 systemd[1]: Started Session 5 of user azureuser. Oct 05 08:06:13 centos7 systemd-logind[570]: New session 5 of user azureuser. Oct 05 08:06:13 centos7 sshd[11236]: pam_unix(sshd:session): session opened for Oct 05 08:06:20 centos7 sudo[11264]: azureuser : TTY=pts/0 ; PWD=/home/azureuser Oct 05 08:06:20 centos7 su[11268]: (to root) azureuser on pts/0 Oct 05 08:06:20 centos7 su[11268]: pam_unix(su-l:session): session opened for us Oct 05 08:08:01 centos7 anacron[2296]: Job `cron.monthly' started Oct 05 08:08:01 centos7 anacron[2296]: Job `cron.monthly' terminated Oct 05 08:08:01 centos7 anacron[2296]: Normal exit (3 jobs run) lines 1-11/11 (END)
末尾から1000件表示する
$ journalctl -e Oct 05 06:42:48 centos7 NetworkManager[559]:(eth0): device state change Oct 05 06:42:48 centos7 NetworkManager[559]: NetworkManager state is now Oct 05 06:42:48 centos7 NetworkManager[559]: (eth0): Activation: Stage 2 Oct 05 06:42:48 centos7 NetworkManager[559]: (eth0): Activation: Stage 1 Oct 05 06:42:48 centos7 NetworkManager[559]: (eth0): Activation: Stage 2 Oct 05 06:42:48 centos7 NetworkManager[559]: (eth0): device state change lines 678-700/1001 72%
カーネルのリングバッファの内容を出力(dmesg)
$ journalctl -k -- Logs begin at Mon 2015-10-05 06:41:58 UTC, end at Mon 2015-10-05 08:08:01 UTC Oct 05 06:41:58 localhost.localdomain kernel: Initializing cgroup subsys cpuset Oct 05 06:41:58 localhost.localdomain kernel: Initializing cgroup subsys cpu Oct 05 06:41:58 localhost.localdomain kernel: Initializing cgroup subsys cpuacct Oct 05 06:41:58 localhost.localdomain kernel: Linux version 3.10.0-229.7.2.el7.x Oct 05 06:41:58 localhost.localdomain kernel: Command line: BOOT_IMAGE=/boot/vml Oct 05 06:41:58 localhost.localdomain kernel: e820: BIOS-provided physical RAM m Oct 05 06:41:58 localhost.localdomain kernel: BIOS-e820: [mem 0x0000000000000000 Oct 05 06:41:58 localhost.localdomain kernel: BIOS-e820: [mem 0x000000000009fc00 Oct 05 06:41:58 localhost.localdomain kernel: BIOS-e820: [mem 0x00000000000e0000 Oct 05 06:41:58 localhost.localdomain kernel: BIOS-e820: [mem 0x0000000000100000 Oct 05 06:41:58 localhost.localdomain kernel: BIOS-e820: [mem 0x000000001fff0000 Oct 05 06:41:58 localhost.localdomain kernel: BIOS-e820: [mem 0x000000001ffff000 Oct 05 06:41:58 localhost.localdomain kernel: BIOS-e820: [mem 0x0000000100000000 Oct 05 06:41:58 localhost.localdomain kernel: bootconsole [earlyser0] enabled
ブートログの出力
$ journalctl -b -- Logs begin at Mon 2015-10-05 06:41:58 UTC, end at Mon 2015-10-05 08:29:49 UTC Oct 05 06:41:58 localhost.localdomain systemd-journal[208]: Runtime journal is u Oct 05 06:41:58 localhost.localdomain systemd-journal[208]: Runtime journal is u Oct 05 06:41:58 localhost.localdomain kernel: Initializing cgroup subsys cpuset Oct 05 06:41:58 localhost.localdomain kernel: Initializing cgroup subsys cpu Oct 05 06:41:58 localhost.localdomain kernel: Initializing cgroup subsys cpuacct Oct 05 06:41:58 localhost.localdomain kernel: Linux version 3.10.0-229.7.2.el7.x Oct 05 06:41:58 localhost.localdomain kernel: Command line: BOOT_IMAGE=/boot/vml Oct 05 06:41:58 localhost.localdomain kernel: e820: BIOS-provided physical RAM m Oct 05 06:41:58 localhost.localdomain kernel: BIOS-e820: [mem 0x0000000000000000 Oct 05 06:41:58 localhost.localdomain kernel: BIOS-e820: [mem 0x000000000009fc00 Oct 05 06:41:58 localhost.localdomain kernel: BIOS-e820: [mem 0x00000000000e0000 Oct 05 06:41:58 localhost.localdomain kernel: BIOS-e820: [mem 0x0000000000100000 Oct 05 06:41:58 localhost.localdomain kernel: BIOS-e820: [mem 0x000000001fff0000 Oct 05 06:41:58 localhost.localdomain kernel: BIOS-e820: [mem 0x000000001ffff000 Oct 05 06:41:58 localhost.localdomain kernel: BIOS-e820: [mem 0x0000000100000000 Oct 05 06:41:58 localhost.localdomain kernel: bootconsole [earlyser0] enabled Oct 05 06:41:58 localhost.localdomain kernel: NX (Execute Disable) protection: a Oct 05 06:41:58 localhost.localdomain kernel: SMBIOS 2.3 present.
過去のブートログを出力(以下1回前のブートログ)
$ [root@centos7 ~]# journalctl -b 1 -- Logs begin at Mon 2015-10-05 10:12:42 UTC, end at Mon 2015-10-05 08:37:20 UTC Oct 05 10:12:42 localhost.localdomain systemd-journal[208]: Runtime journal is u Oct 05 10:12:42 localhost.localdomain systemd-journal[208]: Runtime journal is u Oct 05 10:12:42 localhost.localdomain kernel: Initializing cgroup subsys cpuset Oct 05 10:12:42 localhost.localdomain kernel: Initializing cgroup subsys cpu Oct 05 10:12:42 localhost.localdomain kernel: Initializing cgroup subsys cpuacct Oct 05 10:12:42 localhost.localdomain kernel: Linux version 3.10.0-229.7.2.el7.x Oct 05 10:12:42 localhost.localdomain kernel: Command line: BOOT_IMAGE=/boot/vml Oct 05 10:12:42 localhost.localdomain kernel: e820: BIOS-provided physical RAM m Oct 05 10:12:42 localhost.localdomain kernel: BIOS-e820: [mem 0x0000000000000000 Oct 05 10:12:42 localhost.localdomain kernel: BIOS-e820: [mem 0x000000000009fc00 Oct 05 10:12:42 localhost.localdomain kernel: BIOS-e820: [mem 0x00000000000e0000 Oct 05 10:12:42 localhost.localdomain kernel: BIOS-e820: [mem 0x0000000000100000 Oct 05 10:12:42 localhost.localdomain kernel: BIOS-e820: [mem 0x000000001fff0000 Oct 05 10:12:42 localhost.localdomain kernel: BIOS-e820: [mem 0x000000001ffff000 Oct 05 10:12:42 localhost.localdomain kernel: BIOS-e820: [mem 0x0000000100000000 Oct 05 10:12:42 localhost.localdomain kernel: bootconsole [earlyser0] enabled Oct 05 10:12:42 localhost.localdomain kernel: NX (Execute Disable) protection: a Oct 05 10:12:42 localhost.localdomain kernel: SMBIOS 2.3 present.
ユニット(*1)を指定してログ出力(以下はsshdのログを出力)
$ journalctl -u sshd.service -- Logs begin at Mon 2015-10-05 10:12:42 UTC, end at Mon 2015-10-05 08:37:20 UTC Oct 05 08:33:12 centos7 systemd[1]: Starting OpenSSH server daemon... Oct 05 08:33:12 centos7 systemd[1]: Started OpenSSH server daemon. Oct 05 08:33:12 centos7 sshd[833]: Server listening on 0.0.0.0 port 22. Oct 05 08:33:12 centos7 sshd[833]: Server listening on :: port 22. Oct 05 08:37:05 centos7 sshd[2004]: Accepted password for azureuser from 221.249 lines 1-6/6 (END) (*1)ユニットリストは"systemctl"で取得する。
出力フォーマット変更
【デフォルト】 $ journalctl -o short -- Logs begin at Mon 2015-10-05 10:12:42 UTC, end at Mon 2015-10-05 08:44:09 UTC Oct 05 10:12:42 localhost.localdomain systemd-journal[208]: Runtime journal is u Oct 05 10:12:42 localhost.localdomain systemd-journal[208]: Runtime journal is u Oct 05 10:12:42 localhost.localdomain kernel: Initializing cgroup subsys cpuset Oct 05 10:12:42 localhost.localdomain kernel: Initializing cgroup subsys cpu Oct 05 10:12:42 localhost.localdomain kernel: Initializing cgroup subsys cpuacct Oct 05 10:12:42 localhost.localdomain kernel: Linux version 3.10.0-229.7.2.el7.x Oct 05 10:12:42 localhost.localdomain kernel: Command line: BOOT_IMAGE=/boot/vml Oct 05 10:12:42 localhost.localdomain kernel: e820: BIOS-provided physical RAM m Oct 05 10:12:42 localhost.localdomain kernel: BIOS-e820: [mem 0x0000000000000000 Oct 05 10:12:42 localhost.localdomain kernel: BIOS-e820: [mem 0x000000000009fc00 【タイムスタンプを経過時刻とする】 $ journalctl -o short-monotonic -- Logs begin at Mon 2015-10-05 10:12:42 UTC, end at Mon 2015-10-05 08:44:09 UTC [ 1.783039] localhost.localdomain systemd-journal[208]: Runtime journal is us [ 1.783288] localhost.localdomain systemd-journal[208]: Runtime journal is us [ 0.000000] localhost.localdomain kernel: Initializing cgroup subsys cpuset [ 0.000000] localhost.localdomain kernel: Initializing cgroup subsys cpu [ 0.000000] localhost.localdomain kernel: Initializing cgroup subsys cpuacct [ 0.000000] localhost.localdomain kernel: Linux version 3.10.0-229.7.2.el7.x8 [ 0.000000] localhost.localdomain kernel: Command line: BOOT_IMAGE=/boot/vmli [ 0.000000] localhost.localdomain kernel: e820: BIOS-provided physical RAM ma [ 0.000000] localhost.localdomain kernel: BIOS-e820: [mem 0x0000000000000000- [ 0.000000] localhost.localdomain kernel: BIOS-e820: [mem 0x000000000009fc00- 【テキスト形式で出力】 $ journalctl -o export __CURSOR=s=8ca7e67e1d6c4e148686f88f496d5da7;i=1;b=f427c00d42214ff48a82c1a1d3f038 __REALTIME_TIMESTAMP=1444039962755773 __MONOTONIC_TIMESTAMP=1783039 _BOOT_ID=f427c00d42214ff48a82c1a1d3f0387d PRIORITY=6 _TRANSPORT=driver MESSAGE=Runtime journal is using 4.1M (max 33.5M, leaving 50.2M of free 330.9M, MESSAGE_ID=ec387f577b844b8fa948f33cad9a75e6 【詳細ログの表示】 $ journalctl -o verbose -- Logs begin at Mon 2015-10-05 10:12:42 UTC, end at Mon 2015-10-05 08:49:14 UTC Mon 2015-10-05 10:12:42.755773 UTC [s=8ca7e67e1d6c4e148686f88f496d5da7;i=1;b=f42 PRIORITY=6 _TRANSPORT=driver MESSAGE=Runtime journal is using 4.1M (max 33.5M, leaving 50.2M of free 330. MESSAGE_ID=ec387f577b844b8fa948f33cad9a75e6 _PID=208 _UID=0 _GID=0 _COMM=systemd-journal _EXE=/usr/lib/systemd/systemd-journald _CMDLINE=/usr/lib/systemd/systemd-journald 【JSON形式】 $ journalctl -o json { "__CURSOR" : "s=8ca7e67e1d6c4e148686f88f496d5da7;i=1;b=f427c00d42214ff48a82c1a { "__CURSOR" : "s=8ca7e67e1d6c4e148686f88f496d5da7;i=2;b=f427c00d42214ff48a82c1a { "__CURSOR" : "s=8ca7e67e1d6c4e148686f88f496d5da7;i=3;b=f427c00d42214ff48a82c1a { "__CURSOR" : "s=8ca7e67e1d6c4e148686f88f496d5da7;i=4;b=f427c00d42214ff48a82c1a { "__CURSOR" : "s=8ca7e67e1d6c4e148686f88f496d5da7;i=5;b=f427c00d42214ff48a82c1a { "__CURSOR" : "s=8ca7e67e1d6c4e148686f88f496d5da7;i=6;b=f427c00d42214ff48a82c1a { "__CURSOR" : "s=8ca7e67e1d6c4e148686f88f496d5da7;i=7;b=f427c00d42214ff48a82c1a { "__CURSOR" : "s=8ca7e67e1d6c4e148686f88f496d5da7;i=8;b=f427c00d42214ff48a82c1a { "__CURSOR" : "s=8ca7e67e1d6c4e148686f88f496d5da7;i=9;b=f427c00d42214ff48a82c1a 【JSON形式を見やすく整形】 $ journalctl -o json-pretty { "__CURSOR" : "s=8ca7e67e1d6c4e148686f88f496d5da7;i=1;b=f427c00d42214ff48 "__REALTIME_TIMESTAMP" : "1444039962755773", "__MONOTONIC_TIMESTAMP" : "1783039", "_BOOT_ID" : "f427c00d42214ff48a82c1a1d3f0387d", "PRIORITY" : "6", "_TRANSPORT" : "driver", "MESSAGE" : "Runtime journal is using 4.1M (max 33.5M, leaving 50.2M of "MESSAGE_ID" : "ec387f577b844b8fa948f33cad9a75e6", "_PID" : "208", "_UID" : "0", "_GID" : "0", "_COMM" : "systemd-journal", "_EXE" : "/usr/lib/systemd/systemd-journald", "_CMDLINE" : "/usr/lib/systemd/systemd-journald", "_CAP_EFFECTIVE" : "4402800cf", "_SYSTEMD_CGROUP" : "/system.slice/systemd-journald.service", "_SYSTEMD_UNIT" : "systemd-journald.service", "_SYSTEMD_SLICE" : "system.slice", "_SELINUX_CONTEXT" : "kernel", 【Server-Sent Events用のフォーマット】 $ journalctl -o json-sse data: { "__CURSOR" : "s=8ca7e67e1d6c4e148686f88f496d5da7;i=1;b=f427c00d42214ff48 data: { "__CURSOR" : "s=8ca7e67e1d6c4e148686f88f496d5da7;i=2;b=f427c00d42214ff48 data: { "__CURSOR" : "s=8ca7e67e1d6c4e148686f88f496d5da7;i=3;b=f427c00d42214ff48 data: { "__CURSOR" : "s=8ca7e67e1d6c4e148686f88f496d5da7;i=4;b=f427c00d42214ff48 data: { "__CURSOR" : "s=8ca7e67e1d6c4e148686f88f496d5da7;i=5;b=f427c00d42214ff48 data: { "__CURSOR" : "s=8ca7e67e1d6c4e148686f88f496d5da7;i=6;b=f427c00d42214ff48 data: { "__CURSOR" : "s=8ca7e67e1d6c4e148686f88f496d5da7;i=7;b=f427c00d42214ff48
出力順序を新しい順に出力
$ journalctl -r -- Logs begin at Mon 2015-10-05 10:12:42 UTC, end at Mon 2015-10-05 08:49:14 UTC Oct 05 08:49:14 centos7 ntpd[1992]: 0.0.0.0 c618 08 no_sys_peer Oct 05 08:49:12 centos7 systemd[1]: Time has been changed Oct 05 08:49:12 centos7 ntpd[1992]: 0.0.0.0 c61c 0c clock_step -0.410329 s Oct 05 08:49:12 centos7 ntpd[1992]: 0.0.0.0 c612 02 freq_set kernel -419.899 PPM Oct 05 08:47:51 centos7 systemd[1]: Started Cleanup of Temporary Directories. Oct 05 08:47:50 centos7 systemd[1]: Starting Cleanup of Temporary Directories... Oct 05 08:44:09 centos7 sshd[2071]: Connection closed by 31.44.67.187 [preauth]
ページング機能無効(lessっぽい表示を無効にする)
$ journalctl --no-pager -- Logs begin at Mon 2015-10-05 10:12:42 UTC, end at Mon 2015-10-05 09:04:24 UTC. -- Oct 05 10:12:42 localhost.localdomain systemd-journal[208]: Runtime journal i... Oct 05 10:12:42 localhost.localdomain systemd-journal[208]: Runtime journal i... Oct 05 10:12:42 localhost.localdomain kernel: Initializing cgroup subsys cpuset Oct 05 10:12:42 localhost.localdomain kernel: Initializing cgroup subsys cpu Oct 05 10:12:42 localhost.localdomain kernel: Initializing cgroup subsys cpuacct Oct 05 10:12:42 localhost.localdomain kernel: Linux version 3.10.0-229.7.2.e...5 Oct 05 10:12:42 localhost.localdomain kernel: Command line: BOOT_IMAGE=/boot...6 Oct 05 10:12:42 localhost.localdomain kernel: e820: BIOS-provided physical R...: Oct 05 10:12:42 localhost.localdomain kernel: BIOS-e820: [mem 0x000000000000...e Oct 05 10:12:42 localhost.localdomain kernel: BIOS-e820: [mem 0x000000000009...d Oct 05 10:12:42 localhost.localdomain kernel: BIOS-e820: [mem 0x00000000000e...d Oct 05 10:12:42 localhost.localdomain kernel: BIOS-e820: [mem 0x000000000010...e Oct 05 10:12:42 localhost.localdomain kernel: BIOS-e820: [mem 0x000000001fff...a Oct 05 10:12:42 localhost.localdomain kernel: BIOS-e820: [mem 0x000000001fff...S Oct 05 10:12:42 localhost.localdomain kernel: BIOS-e820: [mem 0x000000010000...e Oct 05 10:12:42 localhost.localdomain kernel: bootconsole [earlyser0] enabled Oct 05 10:12:42 localhost.localdomain kernel: NX (Execute Disable) protectio...e Oct 05 10:12:42 localhost.localdomain kernel: SMBIOS 2.3 present.
ログレベルに準じたフィルタ出力(以下は4:warning)
【名称】 $ journalctl -p warning -- Logs begin at Mon 2015-10-05 10:12:42 UTC, end at Mon 2015-10-05 09:04:24 UTC Oct 05 10:12:42 localhost.localdomain kernel: ACPI: RSDP 00000000000f56f0 00014 Oct 05 10:12:42 localhost.localdomain kernel: ACPI: RSDT 000000001fff0000 00040 Oct 05 10:12:42 localhost.localdomain kernel: ACPI: FACP 000000001fff0200 00081 Oct 05 10:12:42 localhost.localdomain kernel: ACPI: DSDT 000000001fff1724 02E78 Oct 05 10:12:42 localhost.localdomain kernel: ACPI: FACS 000000001ffff000 00040 Oct 05 10:12:42 localhost.localdomain kernel: ACPI: WAET 000000001fff1480 00028 Oct 05 10:12:42 localhost.localdomain kernel: ACPI: SLIC 000000001fff14c0 00176 Oct 05 10:12:42 localhost.localdomain kernel: ACPI: OEM0 000000001fff16c0 00064 【数値】 $ journalctl -p 4 -- Logs begin at Mon 2015-10-05 10:12:42 UTC, end at Mon 2015-10-05 09:04:24 UTC Oct 05 10:12:42 localhost.localdomain kernel: ACPI: RSDP 00000000000f56f0 00014 Oct 05 10:12:42 localhost.localdomain kernel: ACPI: RSDT 000000001fff0000 00040 Oct 05 10:12:42 localhost.localdomain kernel: ACPI: FACP 000000001fff0200 00081 Oct 05 10:12:42 localhost.localdomain kernel: ACPI: DSDT 000000001fff1724 02E78 Oct 05 10:12:42 localhost.localdomain kernel: ACPI: FACS 000000001ffff000 00040 Oct 05 10:12:42 localhost.localdomain kernel: ACPI: WAET 000000001fff1480 00028 Oct 05 10:12:42 localhost.localdomain kernel: ACPI: SLIC 000000001fff14c0 00176 Oct 05 10:12:42 localhost.localdomain kernel: ACPI: OEM0 000000001fff16c0 00064 ※以下のレベルで取得可能 0:emerg 1:alert 2:crit 3:err 4:warning 5:notice 6:info 7:debug
OS、NW設定系
ホスト名の確認($ hostnameでも可)
$ hostnamectl Static hostname: centos7 Icon name: computer-desktop Chassis: desktop Machine ID: 99f30b6b81444d47a888f0313c428bd8 Boot ID: 223d220ec8404003bd4330e609c14bb8 Virtualization: microsoft Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-229.7.2.el7.x86_64 Architecture: x86_64
ホスト名の変更
$ hostnamectl set-hostname new_hostname
全ての起動インターフェース情報
$ /sbin/ip a 1: lo:mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0d:3a:40:32:5b brd ff:ff:ff:ff:ff:ff inet 100.74.2.48/23 brd 100.74.3.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::20d:3aff:fe40:325b/64 scope link valid_lft forever preferred_lft forever
インターフェースを指定した情報表示
$ /sbin/ip a s dev eth0 2: eth0:mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0d:3a:40:32:5b brd ff:ff:ff:ff:ff:ff inet 100.74.2.48/23 brd 100.74.3.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::20d:3aff:fe40:325b/64 scope link valid_lft forever preferred_lft forever
ルーティングテーブルの表示
$ /sbin/ip r default via 100.74.2.1 dev eth0 proto static metric 100 100.74.2.0/23 dev eth0 proto kernel scope link src 100.74.2.48 metric 100 100.74.96.90 via 100.74.2.1 dev eth0 proto dhcp metric 100
デフォルトゲートウェイの追加
$ /sbin/ip r a default via 100.74.2.1
デフォルトゲートウェイの削除
※注意 不用意に実施すると環境によってはログインできなくなります。 デフォルトルートを新規に作成して試すようにして下さい。 $ /sbin/ip r d default via 100.74.2.1
インターフェースの統計情報
$ ip -s l 1: lo:mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 RX: bytes packets errors dropped overrun mcast 0 0 0 0 0 0 TX: bytes packets errors dropped carrier collsns 0 0 0 0 0 0 2: eth0: mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000 link/ether 00:0d:3a:40:32:5b brd ff:ff:ff:ff:ff:ff RX: bytes packets errors dropped overrun mcast 656441 1799 0 0 0 0 TX: bytes packets errors dropped carrier collsns 345956 2327 0 0 0 0
ARPテーブル表示
$ /sbin/ip n 100.74.2.80 dev eth0 lladdr f4:52:14:53:52:50 REACHABLE 100.74.2.1 dev eth0 lladdr 88:f0:31:c1:63:7c REACHABLE
ユーザーモード、起動モード系
シングルユーザモードへ移行
※注意 不用意に実施すると再度ログインできなくなります。 もしやってしまった場合は、コンソールから再起動してください。 試す前にランレベル1でも対応できるようにしておくといいです。 Linux - ターミナル接続できない仮想マシンでシングルユーザーモード作業するには - Qiita $ systemctl rescue Broadcast message from usernema@hostname on pts/0 (Tue 2015-10-06 00:04:26 UTC): The system is going down to rescue mode NOW!
マルチユーザーモードへ移行
$ systemctl default
ランレベルの変更
【起動モード】 $ systemctl isolate target_name 【標準起動モード】 $ systemctl set-default target_name target_nameは以下を参照 0 システム停止 poweroff.target 1 シングルユーザモード rescue.target 3 マルチユーザモード multi-user.target 5 グラフィカルモード graphical.target 6 再起動 reboot.target N/A 緊急モード emergency.target
Linux触り始めて頃はSysV Initコマンドもチンプンカンプンでしたが、慣れれば勝手に手が動くようになっていました。
同じ事だしこれからは主流になっていくと思うので、これから自分で作るサーバは全てVer.7で作ろう。