CentOS 7 has been changed from UNIX System V Init, which was conventionally used, to Systemd.
Therefore, the management command has changed significantly.
Item | RHEL6/CentOS6 | RHEL7/CentOS7 |
---|---|---|
Boot | init process | systemd - Move in parallel Faster booting |
kernel | 2.6.x-x | 3.10.x-x |
File System | ext4 | xfs |
NIC | eth0 Start Number is 0 | eno1 : en = Ether Net , o = On bord ens1 : en = Ether Net , s = PCI Start Number is 1 |
Log | rsyslog | journal(Binary)とrsyslog(Text) |
ntp | ntpd | chronyd |
FW | iptables | firewalld or iptables (Only one can be used) |
Location of runtime data after boot | /var/run | /run |
root/src/udev/udev-builtin-net_id.c
* Two character prefixes based on the type of interface: * en -- ethernet * sl -- serial line IP (slip) * wl -- wlan * ww -- wwan * * Type of names: * b<number> -- BCMA bus core number * ccw<name> -- CCW bus group name * o<index>[d<dev_port>] -- on-board device index number * s<slot>[f<function>][d<dev_port>] -- hotplug slot index number * x<MAC> -- MAC address * [P<domain>]p<bus>s<slot>[f<function>][d<dev_port>] * -- PCI geographical location * [P<domain>]p<bus>s<slot>[f<function>][u<port>][..][c<config>][i<interface>] * -- USB port number chain
https://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c#n20
Unit | Service Unit(.service) :Used to start the daemon Socket Unit(.socket) Device Unit Mount Unit etc |
Item | RHEL6/CentOS6 | RHEL7/CentOS7 |
---|---|---|
Stop | shutdown -h now halt (Power OFF) | poweroff systemctl poweroff systemctl halt (Stop the OS but do not turn off the power) halt (Stop the OS but do not turn off the power) |
Rebbot | reboot shutdown -r now | reboot systemctl reboot |
Syngle User Mode | init S | systemctl rescue |
Standard runlevel change | /etc/inittab Edit | systemctl set-default multi-user.target |
Standard target confirmation Runlevel | who -r runlevel | systemctl get-default |
RHEL7/CentOS7 Commands | Note |
---|---|
systemctl list-units --type=target --all | Confirm Available Targets |
systemctl isolate rescue.target | Temporary switching of target |
systemctl list-dependencies graphical.target |grep target |
RHEL6/CentOS6 Runlevel | RHEL7/CentOS7 Target | Note |
---|---|---|
init 0 | poweroff.target | Stop System |
init 1 | rescue.target | Single User Mode |
init 3 | multi-user.target | Multi User Mode CUI |
init 5 | graphical.target | Graphical Mode GUI Graphical Login |
init 6 | reboot.target | reboot |
N/A | emergency.target | Emergency Mode |
Item | RHEL6/CentOS6 | RHEL7/CentOS7 |
---|---|---|
Service status check (individually) | service SERVICE status /etc/init.d/SERVICE status | systemctl status UNIT |
Confirm service auto start setting | chkconfig --list chkconfig --list SERVICE | systemctl list-unit-files (Also show non-service) systemctl list-unit-files -t service (Only Service) systemctl is-enabled UNIT enabled : auto start disabled : not autostart |
Service status check | systemctl systemctl list-units systemctl -t service (Only services that are running) systemctl |grep service (Only services that are running) systemctl -t service --all (All Service) -Active is the active service |
|
The location of the service to be activated | ls /etc/init.d/ | ls /usr/lib/systemd/system/*.service ls /etc/systemd/system/*.service |
RHEL7/CentOS7Command | Note |
---|---|
systemctl is-active sshd | |
systemctl is-enabled sshd | |
systemctl list-units --type=service | |
systemctl list-units --type=service --all | Inactive unit also displayed |
systemctl list-unit-files --type=service | |
systemctl --failed --type=service |
Item | RHEL6/CentOS6 | RHEL7/CentOS7 |
---|---|---|
Start Service | service SERVICE start /etc/init.d/SERVICE start | systemctl start UNIT |
Stop Service | service SERVICE stop /etc/init.d/SERVICE stop | systemctl stop UNIT |
Reboot Service | service SERVICE restart /etc/init.d/SERVICE restart | systemctl restart UNIT |
Reload service settings | service SERVICE reload /etc/init.d/SERVICE reload | systemctl reload UNIT |
Automatic start of service | chkconfig SERVICE on | systemctl enable UNIT |
Automatic service deactivation | chkconfig SERVICE off | systemctl disable UNIT |
Forced termination of service | kill -9 PROCESS-ID | systemctl kill -s 9 UNIT systemctl kill --signal=9 UNIT |
# systemctl status sshd.service sshd.service - OpenSSH server daemon Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled) Active: active (running) since Month 2016-05-30 06:46:08 JST; 1h 45min ago Main PID: 1054 (sshd) CGroup: /system.slice/sshd.service mq1054 /usr/sbin/sshd -D May 30 06:46:08 centos7 systemd[1]: Started OpenSSH server daemon. May 30 06:46:08 centos7 sshd[1054]: Server listening on 0.0.0.0 port 22. May 30 06:46:08 centos7 sshd[1054]: Server listening on :: port 22. May 30 08:26:38 centos7 sshd[2592]: Accepted password for root from 192.168.56.1 port 52987 ssh2
enabled | It is activated at boot time |
disabled | Not booted at boot time |
active(running) | One or more processes are running |
active(exited) | Successful completion |
active(waiting) | Running but waiting for an event |
failed | Failed to execute |
inactive | It is not running |
Item | RHEL6/CentOS6 | RHEL7/CentOS7 |
---|---|---|
Host name setting file | /etc/sysconfig/network | /etc/hostname |
Host name confirmation | hostname | hostname hostnamectl hostnamectl status |
Temporarily change the host name | hostname NEW-HOSTNAME | hostname NEW-HOSTNAME |
Permanently change the host name | Edit /etc/sysconfig/network | hostnamectl set-hostname NEW-HOSTNAME hostnamectl set-hostname test-server-01 |
Item | RHEL6/CentOS6 | RHEL7/CentOS7 |
---|---|---|
Interface settings | /etc/sysconfig/network-scripts/ifcfg-XXXX | |
default gateway | /etc/sysconfig/network | |
Static route | /etc/sysconfig/static-routes | |
Display device list | ifconfig -a | nmcli device nmcli d *NetworkManager Requires activation |
IP, MAC confirmation | ifconfig ip addr | ip a ip addr ip address show nmcli dev show |
Routing table display | route netsat -rn ip r ip ro ip route ip route show | ip r ip ro ip route ip route show |
Add routing | route add default gw xx.xx.xx.xx | ip route add default via xx.xx.xx.xx |
Routing deleted | route del default gw xx.xx.xx.xx | ip route del default via xx.xx.xx.xx |
Add default gateway | route add default gw 192.168.122.1 | ip route add default via 192.168.122.1 |
Delete default gateway | route del default gw 192.168.122.1 | ip route del default via 192.168.122.1 |
Check boot port | netstat -an | ss -an ss -lp (listen port) |
Item | RHEL6/CentOS6 | RHEL7/CentOS7 |
---|---|---|
Time synchronization confirmation | ntpq -p | chronyc sources chronyc sources -v chronyc tracking ← check System time for difference of NTP Server |
Item | RHEL6/CentOS6 | RHEL7/CentOS7 |
---|---|---|
Check Time Zone | date strings /etc/localtime | timedatectl status |
List Time Zone | tree /usr/share/zoneinfo | timedatectl list-timezones |
Change Time Zone | (1)/etc/localtime (2)/etc/sysconfig/clock See below | timedatectl set-timezone Asia/Tokyo |
Setting for system clock
# cp -p /etc/localtime /etc/localtime.org # ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
Hardware clock setting
Corresponding to the fact that the time zone does not return to UTC upon restart
ZONE="Asia/Tokyo" UTC=false
Item | RHEL6/CentOS6 | RHEL7/CentOS7 |
---|---|---|
Confirm system locale | localectl status | |
Available locale list | localectl list-locales localectl list-locales |grep -i ja |
|
Change system locale | localectl set-locale LANG=ja_JP.utf8 | |
Language setting file | /etc/sysconfig/i18n | /etc/locale.conf Set by localectl command (see below) |
Keymap | /etc/sysconfig/keyboard KEYTABLE=“jp106” MODEL=“jp106” LAYOUT=“jp” | localectl set-keymap jp106 setting file :/etc/vconsole.conf KEYMAP=“jp106” |
Even if LANG is set, LANG is overwritten by /etc/profile.d/lang.sh depending on the environment variable of the connection source terminal when ssh login is done.
For example, on the same server, LANG = C if LANG = C terminal, LANG = ja_JP.UTF-8 if LANG=UTF-8 terminal.
If you want to standardize on the server, you also need to set LANG in /etc/profile.
In /etc/profile, read /etc/locale.conf.
LANG="ja_JP.UTF-8"
... #LANG . /etc/locale.conf export LANG
Even if LANG is set, LANG is overwritten by /etc/profile.d/lang.sh depending on the environment variable of the connection source, so if you want to unify it, add it to /etc/profile Also you need to set LANG.
内容 | ext3/4 | XFS |
---|---|---|
Create File System | mkfs.ext4, mkfs.ext3 | mkfs.xfs |
Check File System | e2fsck | xfs_repair |
Display File System Information | dumpe2fs | xfs_info |
Resizing the file system | resize2fs | xfs_growfs |
File system labeling or tuning | tune2fs | xfs_admin |
Saving an image of a file system | e2image | xfs_metadump and xfs_drestore |
File system backup | dump and restore | xfsdump and xfsrestore |
Item | RHEL6/CentOS6 | RHEL7/CentOS7 |
---|---|---|
Real time display of logs | tail -f /var/log/messages | journalctl -f tail -f /var/log/messages |
Startup log | dmesg | journalctl --dmesg dmesg |
Obtain log of specific service | grep sshd /var/log/secure | journalctl -u sshd grep sshd /var/log/secure |
RHEL7/CentOS7 Commands | Description |
---|---|
journalctl -e | View recent logs |
journalctl -xe | Show recent detail log |
journalctl --disk-usage | Confirm consumption capacity on disk |
journalctl -b | Confirm log at boot |
journalctl -b -1 | Confirm the previous boot log |
journalctl -n 5 | Display only the latest 5 lines |
journalctl -p err | Confirm by specifying priority |
journalctl --since today | Check today's log only |
journalctl --since "2014-02-10 20:30:00" --until "2014:02-13 12:00:00" | |
journal -o verbose | |
journalctl _SYSTEMD_UNIT=sshd.service |