Permanently disabling specific services in Directadmin

By entering the Admin Tools/Service Monitor area, you can see the installed services and instantly close the ones you want. Even if you close them, they will start again when the server restarts.

  • da-popb4smtp
  • directadmin
  • dovecot
  • exim
  • litespeed
  • mysqld
  • named
  • pure-ftpd
  • sshd

There are 9 services running in total. This varies in every server depending on your server or the plugins you have installed. Therefore, do not perform operations without checking the service monitor area in the Direct Admin panel.

First, via SSH;

/usr/local/directadmin/data/admin/services.status

By entering this area, we can turn the service we want to close on or off with OFF or ON. After editing and saving this area, you need to continue below to make it permanent.

We can choose not to run the ones we want after a reboot. For example, on servers where mail and DNS parts are completely on external service providers;

systemctl disable da-popb4smtp
systemctl disable dovecot
systemctl disable exim
systemctl disable named (do not give this command, named is different and I explained it below)
systemctl disable pure-ftpd

By using this, we can prevent the above services from starting automatically after a reboot. With this command, brute force attacks are minimized.
We can prevent brute force attacks by changing the SSH port, so we are not closing that. By activating the FTP section only when necessary, we can keep resource consumption to a minimum.

If a service is needed momentarily, for example FTP, etc.;

service pure-ftpd start

Pure FTP can be started with this.

If we want the server to restart the relevant service on every restart, we must re-enable the services we disabled above. You can do this for each service as in the example below.

systemctl enable pure-ftpd

For the named service, i.e., DNS service, the situation is different from the above;
First;
Step 1:

 /usr/local/directadmin/data/admin/services.status

In this section, we set named to OFF.
We give the following 2 commands in order. (For Centos 7, as below)

/sbin/service named stop
chkconfig named off

If you are using Freebsd;

/usr/local/etc/rc.d/named stop

It is a single command and you give this one.

Step 2:

We open the file below (in one of the 2 files for Centos 7);

/etc/systemd/system/named.service
or
/usr/lib/systemd/system/named.service

You may prefer to back it up, otherwise, you will have trouble if you want to reactivate it later.

Afterwards, inside it;

#!/bin/sh
exit 0;

We write this. A # can be added to the beginning of the others or they can be deleted.
I backed it up with the command below;

cp /etc/systemd/system/named.service /etc/systemd/system/named.serviceyedek

TO BE CONTINUED NOT FINISHED…