How to Start, Stop and Restart Services in Linux

How to Start, Stop and Restart Services in Linux

What Do I Need?

  • A Dedicated or VPS Linux Server
  • Ubuntu

What are Services?

Services on Linux are really important. They’re programs that run in the background outside the interactive control of system users as they lack an interface. The reason for this is that some of these services are crucial for the correct functioning of the operating system.

  1. How to List Services with Systemctl
  1. Open the terminal and let’s get started:
su

  1. Next, list all services in your deployment:
sudo  systemctl list-unit-files --type service --all

How to Start, Stop and Restart Services in Linux

  1. Combine it with the grep command and you can display the services that are actually running:
sudo systemctl ¦ grep running

How to Start, Stop and Restart Services in Linux

  1. Start a Service
  1. To start a service in Linux, you just start the service referencing the service name from the list done above:
systemctl start <service-name>

  1. Stop a Service
  1. To stop a systemd service, you can use the stop option flag of the systemctl command:
systemctl stop <service-name>

  1. Restart a Service
  1. To restart a service in Linux with systemd, you can use:
systemctl restart <service-name>

  1. Check the Status of a Service
  1. You can easily confirm that you’ve successfully executed a particular action by printing the service status:
systemctl status <service-name>

How to Start, Stop and Restart Services in Linux

  1. Managing Services using Init
  1. Start by listing all of your web server’s services:
service --status-all

How to Start, Stop and Restart Services in Linux

  1. The services shown with a [-] are disabled and the services shown with [+] are enabled.
  1. Start a Service
  1. Start services using the following command:
service <service-name> start

  1. Stop a Service
  1. Stopping a service is just as easy:
service <service-name> stop

  1. Restart a Service
  1. It’s not always necessary to restart your entire web service in order for changes to take effect; instead, you restart the appropriate service:
service <service-name> restart

  1. Check the Status of a Service
  1. You should regularly check that you’re getting intended results after changes and this can be done by outputting your service status:
service <service-name> status

How to Start, Stop and Restart Services in Linux

  1. This, crucially, will help you to identify what services are running or failing as appropriate.

Next Steps

I’m going to repeat what I recommend to literally everyone I talk to about web server hosting – always check your updates and upgrades and keep an eye on your access logs. Doing this will make sure you stay protected from bad actors and hackers.

Conclusion

When working with an active, production-ready server, there will be times when services just inexplicably crash out or stall. When this happens, always make sure you’re checking access and service logs as an indicator of a bad actor reconnoitering your service is sudden excessive loads on your services and accompanying memory and bandwidth utilization increases. Sudden spikes in activity aren’t unexpected, especially if you’re running a server that houses multiple e-commerce websites. However, prolonged periods of utility can be indicative of something different, so keep an eye on those logs. Check regularly and check often.

This is also a good opportunity for engagement with your clients using your facilities if that’s the use case you’re dealing with. A lot of the biggest security issues arise from human error. Try to develop and instill in your clients the culture of constant security; for example, ensuring that usernames and passwords aren’t the same or stored in a plain text format on an unencrypted device. Also, make sure clients are aware of common social engineering attack vectors like phishing and spear-phishing. I’d personally recommend deploying enforced two-factor authentication on all logins, be it your web server, webspace, email, or any WordPress installation on your server. Remember, in the real world, most successful hacks don’t involve a complex script or cool looking gadget, just an absent-minded human.

  • Click this link and all your queries to best hosting will end.

How To Set up a VSFTPD Server on a CentOS 7 VPS or Dedicated Server

Brief Description FTP is usually insecure exposing clear-text passwords, userna
2 min read
Avi Ilinsky
Avi Ilinsky
Hosting Expert

How To Set up a VSFTPD Server on an Ubuntu 16.04 VPS or Dedicated Server

Brief Description FTP data is usually insecure since information (usernames, pa
2 min read
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert

How to use phpMyAdmin to develop a website (without MySQL experience)

Brief description A web developer who is not well versed into coding websites f
2 min read
Idan Cohen
Idan Cohen
Marketing Expert

How to Install MySQL on a Windows Web Server Running Apache

This tutorial will show you how to install the MySQL database on a Windows serve
3 min read
Michael Levanduski
Michael Levanduski
Expert Hosting Writer & Tester
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top