Cadastre-se agora para um orçamento mais personalizado!

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

01 de novembro de 2023 Hi-network.com
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 GUIora 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: Thebest 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 thepscommand piped togreplike so:

psaux grepssh

The ps command reports a snapshot of a current process. Theaux 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 ofps auxas the input for thegrep 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 (thed, 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 thesystecmctlcommand. 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 theps aux grepcommand doesn't help you, you can always google the service in question, such asWhat is the daemon for SSH called or what is the daemon for the Apache web server called?

Linux

The best Linux laptops for consumers and developersWant to save your aging computer? Try these 5 Linux distributionsThe best distros for beginnersHow to enable Linux on your Chromebook (and why you should)
  • The best Linux laptops for consumers and developers
  • Want to save your aging computer? Try these 5 Linux distributions
  • The best distros for beginners
  • How to enable Linux on your Chromebook (and why you should)

tag-icon Tags quentes : Tecnologia Nosso processo Serviços & Software Sistemas Operacionais LINUX

Copyright © 2014-2024 Hi-Network.com | HAILIAN TECHNOLOGY CO., LIMITED | All Rights Reserved.