Why you can trust ZDNET : ZDNET independently tests and researches products to bring you our best recommendations and advice. When you buy through our links, we may earn a commission. Our process

'ZDNET Recommends': What exactly does it mean?

ZDNET's recommendations are based on many hours of testing, research, and comparison shopping. We gather data from the best available sources, including vendor and retailer listings as well as other relevant and independent reviews sites. And we pore over customer reviews to find out what matters to real people who already own and use the products and services we’re assessing.

When you click through from our site to a retailer and buy a product or service, we may earn affiliate commissions. This helps support our work, but does not affect what we cover or how, and it does not affect the price you pay. Neither ZDNET nor the author are compensated for these independent reviews. Indeed, we follow strict guidelines that ensure our editorial content is never influenced by advertisers.

ZDNET's editorial team writes on behalf of you, our reader. Our goal is to deliver the most accurate information and the most knowledgeable advice possible in order to help you make smarter buying decisions on tech gear and a wide array of products and services. Our editors thoroughly review and fact-check every article to ensure that our content meets the highest standards. If we have made an error or published misleading information, we will correct or clarify the article. If you see inaccuracies in our content, please report the mistake via this form.


How to start, stop, and restart a service on any systemd-powered Linux distribution

You may never have to stop, start, or restart a service on Linux, but on the off chance you do, there's a very handy command line tool that makes the process very easy.
Written by Jack Wallen, Contributing Writer
Penguins diving into water
David Merron Photography/Getty Images

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.

1. Open your terminal application

The first thing you must do is open the terminal application found in your desktop menu.

2. Locating the name of the service

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:

ps aux | grep ssh

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.

3. Start the SSH service

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

4. Stop the SSH service

To stop the SSH servive, the command is:

sudo systemctl stop sshd

5. Restart the SSH service

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?

Editorial standards