Comparison of the service utility with systemctl – RHEL-7


In this post we are going to Comparison of the service utility with systemctl. In previous Redhat versions init scripts are used which is located at /etc/init.d directory. These are the bash scripts and used to control the state of services and daemons. Init scripts are replaced with service units in RHEL 7. Extension for the service files are .service work similar to init scripts. Systemctl command used to start, stop, restart, enable, or disable system services. The service and chkconfig commands are also still available. Below table describes a Comparison of the service utility with systemctl.




Comparison of the service utility with systemctl


Service
Systemctl
Description
service name start
systemctl start name.service
Starts a service.
service name stop
systemctl stop name.service
Stops a service.
service name restart
systemctl restart name.service
Restarts a service.
service name condrestart
systemctl try-restart name.service
Restarts a service only if it is running.
service name reload
systemctl reload name.service
Reloads configuration
service name status
systemctl status name.service
Checks if a service is running
systemctl is-active name.service
service --status-all
systemctl list-units --type service --all
Displays the status of all services

Chkconfig
Systemctl
Description
chkconfig name on
systemctl enable name.service
Enables a service
chkconfig name off
systemctl disable name.service
Disables a service.
chkconfig --list name
systemctl status name.service
Checks if a service is enabled
systemctl is-enabled name.service
chkconfig --list
systemctl list-unit-files --type service
Lists all services and checks if they are enabled.
chkconfig --list
systemctl list-dependencies --after
Lists services that are ordered to start before the specified unit
chkconfig --list
systemctl list-dependencies --before
Lists services that are ordered to start after the specified unit

SysV init Commands with systemctl Comparison

Old Command New Command Description
runlevel systemctl list-units --type target
Lists currently loaded target
units.
telinit runlevel systemctl isolate name.target Changes the current target.
 

Some chkconfig commands are below:

List the current runlevels where the services will be starting
# chkconfig --list httpd
httpd                     0:off      1:off      2:off      3:off      4:off      5:off      6:off



Enabling the service on runlevel 2,3,4 and 5 without specifying any runlevel
# chkconfig httpd on
httpd                     0:off      1:off      2:on       3:on       4:on       5:on       6:off 

Some systemctl commands are below:

To Display the Default target unit
# systemctl get-default

To View the Current Target
# systemctl list-units --type target
 
To List All Loaded Units
# systemctl list-units --type target --all




 
 

Comments

Popular posts from this blog

How to install glibc 2.14 on RHEL 6/ RHEL 7/ CentOS 7

Export and Import users/groups and OU in AD Server 2008 using LDIFDE command.

How to Set Up and Configure latest yum repository on CentOS