Skip to content

Instantly share code, notes, and snippets.

@samdoran
Last active November 10, 2017 15:48
Show Gist options
  • Save samdoran/6e4ecd177e75fc03bd1c to your computer and use it in GitHub Desktop.
Save samdoran/6e4ecd177e75fc03bd1c to your computer and use it in GitHub Desktop.
RHEL7 for Seasoned Sysadmins

RHEL 7 for Seasoned Sysadmins

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.

Services

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]

Network Interfaces

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

Setting Hostname

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]

Firewall

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.

iptables vs firewalld

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment