Tuesday, April 19, 2016

HOWTO: Start, Stop and restart a service on Linux

There are two commands to stop and start and restart a service on Linux sytems which are the followings: service and systemctl


The first command is service:
Syntax :
  service [TheService] [ action ] 
     [ TheService ] = is the service we want to stop or start (eg:iptables, httpd, dhcpd, ..)
     [ action ] = stop, start, restart (in our case).

Let use iptables in our example, to stop iptables service using service command we need to type the following command:
service iptables restart
 you can replace restart with the action you want.
service iptables restart/stop/start

The Second command is systemctl:

 Syntax :
  systemctl [ action ] [TheService]

    [ TheService ] = is the service we want to stop or start (eg:iptables, httpd, dhcpd, ..)
     [ action ] = stop, start, restart (in our case).

We will use the same service used on last example, I mean iptables, Let get started it:

In a case to stop the  iptables service we have to type the following:


systemctl stop  iptables
 Also you can start or restart the service using the same command:
 
systemctl restart/stop/start iptables
NB: You must run those commands with Superuser privileges, just type sudo before the command and it'll ask you for Admin password.

 sudo systemctl stop  iptables

That's it, Thank you for visiting our Blog Happy to see you AGAIN, Keep in Touch 

No comments:

Post a Comment

author
My Linux Tricks
MyLinuxTricks's a Blog That intersted in Linux Operating Systems and it try to share some tricks with visitors, and Help who needs help..