System Configuration for RHEL/CentOS 7

System Configuration for RHEL/CentOS7

Changing Default Runlevel

create a soft-links named “default.target” under “/etc/systemd/system” using source path “/lib/systemd/system/<target name>.target For example, changing runlevel into 3.

# ln -sf /lib/systemd/system/runlevel3.target /etc/systemd/system/default.target

OR

# systemctl set-default runlevel3.target


graphical.target is the default. You might want multi-user.target for the equivalent of non graphical (runlevel 3) from sysv init. The full list of targets can be accessed via systemctl list-units –type=target
systemd does not use /etc/inittab file.

Service

Traditional “service <service name> <action>” has been changed as “/bin/systemctl <action> <servicename>.service” for example,

# /bin/systemctl status sshd.service
# /bin/systemctl stop sshd.service
# /bin/systemctl start sshd.service

chkconfig

Traditional “chkconfig <servicename> <action> has been changed as “/bin/systemctl <action><servicename>.service”, where <action> will be either “enable” or “disable”. for example,

# systemctl disable sshd.service
# systemctl enable sshd.service

SystemD cheatsheet

service foobar start systemctl start foobar.service Used to start a service (not reboot persistent)
service foobar stop systemctl stop foobar.service Used to stop a service (not reboot persistent)
service foobar restart systemctl restart foobar.service Used to stop and then start a service
service foobar reload systemctl reload foobar.service When supported, reloads the config file without interrupting pending operations.
service foobar condrestart systemctl condrestart foobar.service Restarts if the service is already running.
service foobar status systemctl status foobar.service Tells whether a service is currently running.
ls /etc/rc.d/init.d/ ls /lib/systemd/system/*.service /etc/systemd/system/*.service Used to list the services that can be started or stopped
chkconfig foobar on systemctl enable foobar.service Turn the service on, for start at next boot, or other trigger.
chkconfig foobar off systemctl disable foobar.service Turn the service off for the next reboot, or any other trigger.
chkconfig foobar systemctl is-enabled foobar.service Used to check whether a service is configured to start or not in the current environment.
chkconfig foobar –list ls /etc/systemd/system/*.wants/foobar.service Used to list what levels this service is configured on or off
chkconfig foobar –add Not needed, no equivalent.