cmdref.net - Command Reference

This site is command references for system engineers.

User Tools

Site Tools


Top     OS ( Linux )     Middleware     Protocol     Hardware     Programming ( Shell Script )     SiteMap

Sidebar

Top     SiteMap








Reference











.

os:linux:note:rhel7-vs-rhel6.html



Linux

RHEL7/CentOS7 vs RHEL6/CentOS6

Summary of differences

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 : o = On bord
ens1 : s = PCI
en = Ether Net
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

RHEL7/CentOS7 NIC

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


New Term

Unit Service Unit(.service) :Used to start the daemon
Socket Unit(.socket)
Device Unit
Mount Unit
etc


Power

ItemRHEL6/CentOS6RHEL7/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
Other systemctl Commands
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

Comparing Runlevel and Target

RHEL6/CentOS6 RunlevelRHEL7/CentOS7 TargetNote
init 0 poweroff.target Stop System
init 1rescue.target Single User Mode
init 3multi-user.target Multi User Mode CUI
init 5graphical.target Graphical Mode GUI Graphical Login
init 6 reboot.target reboot
N/A emergency.target Emergency Mode


Service

Item RHEL6/CentOS6 RHEL7/CentOS7
The location of the service to be activated ls /etc/init.d/ ls /usr/lib/systemd/system/*.service
ls /etc/systemd/system/*.service
Confirm service auto start setting chkconfig --list
chkconfig --list SERVICE
systemctl list-unit-files -t service (Only Service)
systemctl list-unit-files (Also show non-service)
systemctl is-enabled UNIT
enabled : auto start
disabled : not autostart
Service status check 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
Service status check (individually) service SERVICE status
/etc/init.d/SERVICE status
systemctl status UNIT
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
Other systemctl Command
RHEL7/CentOS7Command Note
systemctl (List-units is omitted)
systemctl list-units
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

Note

  • If bash - completion is installed, you can tab complement with systemctl like Cisco.
    For example, after systemctl there are candidates in two tabs
  • When changing service file of systemd in RHEL 7 / CentOS 7, it is necessary to reflect it with “systemctl daemon-reload”.
  • systemtl status UNIT result shows various information.
    # systemctl status sshd.service
    sshd.service - OpenSSH server daemon
       Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled)      <- You can see the path of the command. Since it is enabled, it is automatically started at OS startup
       Active: active (running) since Month 2016-05-30 06:46:08 JST; 1h 45min ago    <- It is moving now.
     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.            <- Service related logs
     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


Hostname

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


Networking

  • Even in 7 series you can use the ifconfig, route, netsat, arp commands by installing net-tools.
  • There is no change in the setting file.
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)


Clock Time, Time Zone

Clock Time

Item RHEL6/CentOS6 RHEL7/CentOS7
Time synchronization confirmation ntpq -p chronyc sources -v

Time Zone

  • It is recommended not to edit / etc / sysconfig / clock or / etc / localtime, but to set the time zone with the timedatectl command
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

How to cange Time Zone in RHEL6/CentOS6

(1) /etc/localtime

Setting for system clock

# cp -p /etc/localtime /etc/localtime.org
# ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
(2) /etc/sysconfig/clock

Hardware clock setting

Corresponding to the fact that the time zone does not return to UTC upon restart

ZONE="Asia/Tokyo"
UTC=false


Locale(LANG)

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”
Warning

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.

Example of unifying LANG on server

In /etc/profile, read /etc/locale.conf.

/etc/locale.conf
LANG="ja_JP.UTF-8"
/etc/profile
...
#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.


Filesystem

内容 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


Logging

  • Logs are now saved with binary journal.
  • It is also possible to set the rsyslog and save the log as text.
ItemRHEL6/CentOS6RHEL7/CentOS7
Real time display of logs tail -f /var/log/messages journalctl -f
Startup log dmesg journalctl --dmesg
Obtain log of specific service grep sshd /var/log/secure journalctl -u sshd

How to use the journalctl command

Other systemctl command
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


Other Commands




os/linux/note/rhel7-vs-rhel6.html.txt · Last modified: 2017/08/21 by admin