I’ve been using the Linux operating system for decades, so pretty much anything that has to be done, I can handle it, whether the task is completed from a GUI or a terminal window. Starting, stopping, and restarting services happens to be one such task.
For all of you who are new to Linux, don’t be alarmed, it’s not like you’ll have to constantly monitor and maintain services. However, even though the Linux desktop is one heck of a reliable OS, there may be times when you’ll want to stop, start, or restart a service.
Also: The best Linux laptops
If your distribution of choice uses systemd as its startup service, you’ll be glad to know it includes a very handy tool that greatly simplifies the process.
Let me show you how it’s done.
How to start, stop, and restart a systemd service
What you’ll need: To start, stop, or restart a service, you’ll need a Linux distribution that uses systemd. The good news is that most modern Linux distributions opt for systemd.
Also: How to choose the right Linux desktop distribution for you
If you use Ubuntu (or any of its official spins), Linux Mint, elementary OS, Fedora, and countless other distributions, you’re good to go. You’ll also need a user with sudo privileges.
Let’s get to work.
The first thing you must do is open the terminal application found in your desktop menu.
Next, you need to know the name of the service to be started. This can be a bit tricky, because the names aren’t always what you might expect.
Also: 8 things you can do with Linux that you can’t do with MacOS or Windows
For example, let’s say you have the secure shell server installed on your desktop (so you can remotely access the machine from the command line). You might have made some changes to the configuration file and need to stop, start, or restart the service. To locate the name of the service, you can use the ps command piped to grep like so:
The ps command reports a snapshot of a current process. The aux options effectively print all running processes on a system, no matter how they have been executed. We then use the pipe too (the | character) to use the output of ps aux as the input for the grep command, which prints lines that match a pattern (in this case, ssh).
Also: The most important reason you should be using Linux at home
The result of the command will list both ssh and sshd (the d, in this case, indicates it’s a daemon). Now we know our service in question is sshd.
To start, stop, or restart a service on Linux with systemd, we use the systecmctl command. To start the SSH service, that command would be:
sudo systemctl start sshd
To stop the SSH servive, the command is:
To restart the service, you would issue the command:
sudo systemctl restart sshd
And that, my Linux friends, is all there is to starting, stopping, and restarting a service on a systemd-powered Linux distribution. Remember, it’s important to find the name of the service first. If the ps aux | grep command doesn’t help you, you can always google the service in question, such as What is the daemon for SSH called or what is the daemon for the Apache web server called?