Junior
Which command in RedHat Linux can be used to configure automatic service startup at system boot?
sobes.tech AI
Answer from AI
Configuring automatic service startup in Red Hat Enterprise Linux (RHEL) and compatible systems (CentOS, AlmaLinux, Rocky Linux) is primarily done using systemctl.
Main command:
# Enable automatic service startup
systemctl enable <service_name>
Example:
# Enable automatic startup of Apache web server
systemctl enable httpd.service
Depending on the context, other commands may also be used:
systemctl disable <service_name>: Disable automatic service startup.systemctl is-enabled <service_name>: Check if automatic startup is enabled.systemctl list-unit-files --type=service: View a list of all service units with their status (enabled, disabled, etc.).
For older systems (before RHEL 7), which used the SystemV init system, the command was different:
# For SystemV
chkconfig --add <service_name>
chkconfig <service_name> on
However, in modern versions of RHEL and its derivatives, systemctl is the standard.
Important: These commands require superuser (root) privileges.
# Run command as superuser
sudo systemctl enable <service_name>
Thus, the main and recommended method in modern RedHat-like systems is to use systemctl enable <service_name>.