Help Docs Server Administration Linux Server Administration Restarting Services from the Command Line in Linux

Restarting Services from the Command Line in Linux

To address issues or apply configuration changes, it's often necessary to restart specific server services, like Apache, Exim, FTP, or DNS. This typically involves logging into your server via SSH with root or sudo access.

When you make changes on a server or are having problems, it’s common to have to restart certain services (such as Apache, Exim, FTP, and DNS). This could be because a service has crashed, because you’ve made configuration changes, or because of high server load.

To restart services, you will need to log into your server via SSH. Restarting services usually requires root permissions or the the use of sudo (If the commands below don’t work, try adding sudo before the rest of the command). You might need to restart these services:

Apache

Every time you make Apache configuration changes, you need to restart Apache. Apache’s service name is “httpd.” This is the name you’ll use to restart the service.

  1. Log into your server using the terminal program of your choice via SSH. If you haven’t done this before, read Logging into Your Server via Secure Shell (SSH) first.
  2. If your server uses CentOS, CloudLinux, or RHEL 7, type:
    systemctl restart httpd.service

    and press Enter. If your server uses CentOS, CloudLinux, or RHEL 5 or 6, type:


    service httpd restart

    and press Enter.


That’s all! Apache will restart.

Mail

Every time you make changes to your mail service, you need to restart the service. The mail service you have will depend on your server:

Restarting Exim (cPanel Servers)

Exim’s service name is “exim.”

  1. Log into your server using the terminal program of your choice via SSH. If you haven’t done this before, read Logging into Your Server via Secure Shell (SSH) first.
  2. If your server uses CentOS, CloudLinux, or RHEL 7, type:
    systemctl restart exim.service

    and press Enter. If your server uses CentOS, CloudLinux, or RHEL 5 or 6, type:


    service exim restart

    and press Enter.


That’s all! Exim will restart.

Restarting Postfix (Plesk Servers)

Postfix’s service name is “postfix.”

  1. Log into your server using the terminal program of your choice via SSH. If you haven’t done this before, read Logging into Your Server via Secure Shell (SSH) first.
  2. If your server uses CentOS, CloudLinux, or RHEL 7, type:
    systemctl restart postfix.service

    and press Enter. If your server uses CentOS, CloudLinux, or RHEL 5 or 6, type:

    service postfix restart

    and press Enter.

That’s all! Postfix will restart.

SSH

If you change SSH configuration, you’ll need to restart SSH. For example, changing SSH ports requires an SSH restart. The service name for SSH is “sshd.”

  1. Log into your server using the terminal program of your choice via SSH. If you haven’t done this before, read Logging into Your Server via Secure Shell (SSH) first.
  2. If your server uses CentOS, CloudLinux, or RHEL 7, type:
    systemctl restart sshd.service

    and press Enter. If your server uses CentOS, CloudLinux, or RHEL 5 or 6, type:


    service sshd restart

    and press Enter.


That’s all! SSH will restart.

FTP

The default FTP program is Pure FTP. The service name is “pure-ftp.” If you make any configuration changes, you’ll need to restart FTP.

  1. Log into your server using the terminal program of your choice via SSH. If you haven’t done this before, read Logging into Your Server via Secure Shell (SSH) first.
  2. If your server uses CentOS, CloudLinux, or RHEL 7, type:
    systemctl restart pure-ftp.service

    and press Enter. If your server uses CentOS, CloudLinux, or RHEL 5 or 6, type:

    service pure-ftp restart

    and press Enter.

That’s all! The FTP service will restart.

MySQL

MySQL is called “mysql.”

  1. Log into your server using the terminal program of your choice via SSH. If you haven’t done this before, read Logging into Your Server via Secure Shell (SSH) first.
  2. If your server uses CentOS, CloudLinux, or RHEL 7, type:
    systemctl restart mysql.service

    and press Enter. If your server uses CentOS, CloudLinux, or RHEL 5 or 6, type:

    service mysql restart

    and press Enter.

That’s all! MySQL will restart.

Firewall

The most common firewall you’ll have on your server is CSF. Every time you change CSF configurations, you need to reload the firewall rules. Reloading CSF rules is a little different from restarting other services.

  1. Log into your server using the terminal program of your choice via SSH. If you haven’t done this before, read Logging into Your Server via Secure Shell (SSH) first.
  2. In the command line prompt, type:
    csf -r

    and press Enter.


That’s all you need to do! All the CSF rules will reload.

Cron

The “cron” service controls scheduled server tasks.

  1. Log into your server using the terminal program of your choice via SSH. If you haven’t done this before, read Logging into Your Server via Secure Shell (SSH) first.
  2. If your server uses CentOS, CloudLinux, or RHEL 7, type:
    systemctl restart cron.service

    and press Enter. If your server uses CentOS, CloudLinux, or RHEL 5 or 6, type:


    service cron restart

    and press Enter.


That’s all! Cron will restart.

System Logging

Sometimes you’ll have to restart the service that handles all the system and kernel logging for your server. This service is called “syslog.”

  1. Log into your server using the terminal program of your choice via SSH. If you haven’t done this before, read Logging into Your Server via Secure Shell (SSH) first.
  2. If your server uses CentOS, CloudLinux, or RHEL 7, type:
    systemctl restart syslog.service

    and press Enter If your server uses CentOS, CloudLinux, or RHEL 5 or 6, type:


    service syslog restart

    and press Enter.


That’s all! System logging will restart.

Was this article helpful?