How to restart services in Linux

Author: Florence Bailey
Date Of Creation: 23 March 2021
Update Date: 1 July 2024
Anonim
Linux - Start, Stop, Restart Services (Systemd, systemctl, service, init.d )
Video: Linux - Start, Stop, Restart Services (Systemd, systemctl, service, init.d )

Content

This article will show you how to force restart a service (service) in Linux. This can be done with a few simple commands on any Linux distribution.

Steps

  1. 1 Open a terminal. Most Linux distributions have a menu (in the lower left corner of the screen) that contains the Terminal application. Terminal is analogous to the Windows command line.
    • The user interface depends on the Linux distribution, so you may have to find the Terminal application inside one of the menu folders.
    • It is possible that the Terminal application icon will be on the desktop or in the toolbar at the bottom of the screen, rather than in the Menu.
    • On some Linux distributions, the terminal line appears at the top or bottom of the screen.
  2. 2 Enter the command to display a list of all active services. Enter ls /etc/init.d in terminal and press ↵ Enter... The screen displays a list of running services and the corresponding command names.
    • If this command didn't work, enter ls /etc/rc.d/.
  3. 3 Find the command name of the service you want to restart. Typically, the service name (for example, “Apache”) appears on the left side of the screen, and the command name (for example, “httpd” or “apache2” depending on your Linux distribution) appears on the right side of the screen.
  4. 4 Enter the command to restart the service. Enter sudo systemctl restart service in the terminal, where instead of service substitute the name of the service command and then press ↵ Enter.
    • For example, to restart Apache on Ubuntu, enter sudo systemctl restart apache2 in the terminal.
  5. 5 Enter your password when prompted. Enter the superuser password and then click ↵ Enter... The service will be restarted.
    • If the service has not restarted, enter sudo systemctl stop service, click ↵ Enterand then enter sudo systemctl start service.

Tips

  • Using the "chkconfig" command, you can add and remove a service from the startup list.
  • To see a list of absolutely all active services (in all directories), enter ps -A in the terminal.

Warnings

  • Do not stop services you do not know their purpose. Please be aware that some services are required to keep your system running smoothly.