RHEL 7 introduces quite a few changes to how basic things on the system work. This is my scratchpad of how to do things in the new OS.
Show all services
systemctl list-units | grep service
Show all enabled service units
systemctl list-unit-files -t service | grep enabled
Disable service units
systemctl disable [unit file name]
Stop/start service units
systemctl stop [unit file name]
systemctl start [unit file name]
systemctl restart [unit file name]
Read Consistent Network Device Naming for an overview of what the new wacky (but very good and better that ethX
) names mean.
The common tools ifcfg
, route
, and netstat
are not installed by default. You can install them and they will behave as expected, but this is considered the legacy way of doing things and you should move to the new tools.
The "new" tool of choice for working with interfaces is ip
. This command is a bit "closer to the metal" and has been aroung in Linux for quite a while. The if*
and route
commands were always just wrappers on top of ip
.
List interfaces (old ifconfig -a
):
ip link show
Show ip addresses (old ifconfig
):
ip addr show
Show routing table (old route -an
or netstat
-rn):
ip route show
Global default gateway is stored it /etc/sysconfig/network
. Add the following line to create a default gateway:
GATEWAY=192.168.0.1
There is a new tool called hostnamectl
that helps in setting the hostname. The static hostname is stored in /etc/hostname
(used to be in /etc/sysconfig/network
). The transient hostname is stored in memory and does not persist across reboots (the same as hostname tempname.foo.com
in RHEL < 7).
Show currently hostnames:
hostnamectl status
# OR
hostnamectl
Set both transient and static hostname:
hostnamectl set-hostname [fqdn]
Set only transient hostname:
hostnamectl set-hostname --transient [fqdn]
Set only static hostname (in /etc/hostname
):
hostnamectl set-hostname --static [fqdn]
RHEL 7 uses firewalld
instead of iptables
. It is a very robust zone-based firewall that does not require saving or reloading for changes to take affect. Read more in the official documentation.
Show fireawll status
firewall-cmd --state
# OR
systemctl status firewalld
Show all zones
firewall-cmd --get-zones
Show default zone
firewall-cmd --get-default-zone
Set default zone
firewall-cmd --set-default-zone [zone]
Show active zones and their interfaces
firewall-cmd --get-active-zones
Show all settings of a zone, including member interfaces and open ports/services:
firewall-cmd --zone=public --list-all