CentOS7

Systemd Cheat Sheet


View Systemd Information

# systemctl list-dependencies

Show a unit’s dependencies

# systemctl list-sockets

List sockets and what activates

# systemctl list-jobs

View Active systemd jobs

# systemctl list-unit-files

See unit files and their states

# systemctl list-units

Show if units are loaded/active

# systemctl get-default

List default target (like run level)


Working with Services

# systemctl stop SERVICE_NAME

Stop a running service

# systemctl start SERVICE_NAME

Start a service

# systemctl restart SERVICE_NAME

Restart a running service

# systemctl reload SERVICE_NAME

Reload all config files in service

# systemctl status SERVICE_NAME

See if service is running/enabled

# systemctl enable SERVICE_NAME

Enable a service to start on boot

# systemctl disable SERVICE_NAME

Disable service — won’t start on boot

# systemctl show SERVICE_NAME

Show properties of a service (or other unit)

# systemctl -H HOST_ADDRESS status SERVICE_NAME

Run any systemctl command remotely


Changing System States

# systemctl reboot

Reboot the system (reboot.target)

# systemctl poweroff

Power off the system (poweroff.target)

# systemctl emergency

Put in emergency mode (emergency.target)

# systemctl default

Back to default target (multi-user.target)


Viewing Log Messages

# journalctl

Show all collected log messages

# journalctl -u network.service

See network service messages

# journalctl -f

Follow messages as they appear

# journalctl -k

Show only kernel messages


Using Unit Files

Besides services, most systemd commands can work with these unit types:
parths, slices, snapshots, sockets, swaps, targets, and times

COMPARING NET-TOOLS VS. IPROUTE PACKAGE CMMANDS

NET-TOOLS COMMANDS
IPROUTE COMMANDS
arp -a
ip neigh
arp -v
ip -s neigh
arp -s 192.168.1.1 1:2:3:4:5:6
ip neigh add 192.168.1.1 lladdr 1:2:3:4:5:6 dev eth1
arp -i eth1 -d 192.168.1.1
ip neigh del 192.168.1.1 dev eth1
ifconfig -a
ip addr
ifconfig eth0 down
ip link set eth0 down
ifconfig eth0 up
ip link set eth0 up
ifconfig eth0 192.168.1.1
ip addr add 192.168.1.1/24 dev eth0
ifconfig eth0 netmask 255.255.255.0
ip addr add 192.168.1.1/24 dev eth0
ifconfig eth0 mtu 9000
ip link set eth0 mtu 9000
ifconfig eth0:0 192.168.1.2
ip addr add 192.168.1.2/24 dev eth0
netstat
ss
netstat -neopa
ss -neopa
netstat -g
ip maddr
route
ip route
route add -net 192.168.1.0 netmask 255.255.255.0 dev eth0
ip route add 192.168.1.0/24 dev eth0
route add default gw 192.168.1.1
ip route add default via 192.168.1.1

Firewalld commandline Cheat Sheet


Managing firewalld

# firewall-cmd –state

Check whether the firewalld daemon is active

# firewall-cmd –reload

Reload firewall rules and keep state information.


To list detalls of default and active zones

# firewall-cmd –get-default-zone

Print default zone for connections and interfaces.

# firewall-cmd –get-active-zones

Print currently active zones altogether with interfaces
and sources used in these zones.

# firewall-cmd –list-all -zones

List everything added for or enabled in all zones.


To add/remove interfaces to zones

# firewall-cmd –zone=public –change-interface=eth1

To add interface “eth1” to “public” zone


To list/add/remove services to zones

# firewall-cmd –get-services

Print predefined services as a space separated list.

# firewall-cmd –zone=public –add-service=
samba –add-service=samba-client –permanent

Add “samba and samba-client” service to a specific zone.
You may include, “permanent” flag to make this permanent change.

# firewall-cmd –zone=public –list-service

List services configured in public zone


To list and Add ports to firewall

# firewall-cmd –list-port

List ports added for default zone as a space separated list.

# firewall-cmd –zone=public –add-port=5000/tcp

Add ports in a public zone

ページトップへ