Recommended way to disable/enable services?

Message
Author
BV206
Posts: 296
Joined: Sat Mar 09, 2019 11:55 am

Recommended way to disable/enable services?

#1 Post by BV206 »

In MX what is the recommended way to enable or disable startup services that don't appear in Session and Startup / Application Autostart?
I want to keep the useless services below from automatically running. Some of them appear to be listening on the internet for devices or services that don't exist and I think they might be security hazards:

bluetooth (computer doesn't have bluetooth)
saned (no scanner)
cups (no printer)
cups-browsed (no network printer)
avahi-daemon (no network printer or file server)
samba (no network file server)
nmbd (no network file server)
smbd (no network file server)
nfs-common (no network file server)
nfs-kernel-server (no network file server)
openvpn (no vpn)
pppd-dns (no dial-up modem)
ModemManager (no dial-up modem)
unattended-upgrades (I manually check for upgrades very day)


There are several tools and commands I have run across:
sudo sysv-rc-conf
sudo rcconf
sudo update-rc.d [service] disable
sudo systemctl disable --now [service]

but I don't know if they all do the same thing or how they work in MX having both systemd and sysvinit and they don't all appear to work for all services.

Also what is the best way to list running services?
I have been using:
systemctl list-unit-files --type=service --state=enabled
on *buntu and it appears to work on MX but I don't know if it works properly on sysvinit.

User avatar
timkb4cq
Developer
Posts: 3186
Joined: Wed Jul 12, 2006 4:05 pm

Re: Recommended way to disable/enable services?

#2 Post by timkb4cq »

List running services with

Code: Select all

sudo service --status-all
For simply adding or removing services

Code: Select all

sudo update-rc.d [service] defaults   # to add
sudo update-rc.d [service] disable    # to disable but leave init script available to later
sudo update-rc.d [service] enable    
sudo update-rc.d [service] remove     # to remove
is probably best. n.b. - for remove to work the /etc/init.d/[service] file must already have been deleted, and obviously, to add one that file needs to be present.
sysv-rc-conf is quite useful for managing which run levels a particular service will run, but clumsier for removing one entirely since you have to toggle each level currently enabled.
HP Pavillion TP01, AMD Ryzen 3 5300G (quad core), Crucial 500GB SSD, Toshiba 6TB 7200rpm
Dell Inspiron 15, AMD Ryzen 7 2700u (quad core). Sabrent 500GB nvme, Seagate 1TB

User avatar
Jan K.
Posts: 32
Joined: Mon Jan 28, 2019 8:52 am

Re: Recommended way to disable/enable services?

#3 Post by Jan K. »

But... surely the easiest way would be to deselect them at installation time?

User avatar
Head_on_a_Stick
Posts: 919
Joined: Sun Mar 17, 2019 3:37 pm

Re: Recommended way to disable/enable services?

#4 Post by Head_on_a_Stick »

BV206 wrote: Wed May 08, 2019 3:27 pm Also what is the best way to list running services?
I have been using:
systemctl list-unit-files --type=service --state=enabled
That command shows enabled services, to list running services use

Code: Select all

systemd-cgls
Or

Code: Select all

systemd-cgtop
^ That will also show cgroups and their associated resource usage, which can be very useful.

For sysvinit please note that the service --status-all command will only return useful information for init scripts that have a status command and so it cannot list all running services, this is because sysvinit does not offer true process supervision (which is one of the reasons why Debian dropped it).
mod note: Signature removed, please read the forum rules

BV206
Posts: 296
Joined: Sat Mar 09, 2019 11:55 am

Re: Recommended way to disable/enable services?

#5 Post by BV206 »

Jan K. wrote: Wed May 08, 2019 4:21 pm But... surely the easiest way would be to deselect them at installation time?
How?
I installed MX last week and I don't recall the installer having any choices for anything but SAMBA, CUPS and SANE, and as far as I can tell those choices near the end of the installer don't work. I still had to go in afterwards and try to disable everything.

User avatar
towwire
Posts: 645
Joined: Fri Oct 15, 2010 12:15 pm

Re: Recommended way to disable/enable services?

#6 Post by towwire »

BV206 wrote: Wed May 08, 2019 5:56 pm
Jan K. wrote: Wed May 08, 2019 4:21 pm But... surely the easiest way would be to deselect them at installation time?
How?
I installed MX last week and I don't recall the installer having any choices for anything but SAMBA, CUPS and SANE, and as far as I can tell those choices near the end of the installer don't work. I still had to go in afterwards and try to disable everything.
Some times it is worth reading a manual no matter how much knowledge we have.
Open the MX User Manual, go to Figure 2-20: Installer Screen 6. You will find a button "View" under 6d. Service Setting (advanced), if you had checked there you would have seen some of the services, I don't remember all that are there. You will now know for when you ever need to install again.
It is easier to fight for one's principles then to live up to them.

BV206
Posts: 296
Joined: Sat Mar 09, 2019 11:55 am

Re: Recommended way to disable/enable services?

#7 Post by BV206 »

towwire wrote: Wed May 08, 2019 8:14 pm Open the MX User Manual, go to Figure 2-20: Installer Screen 6. You will find a button "View" under 6d. Service Setting (advanced), if you had checked there you would have seen some of the services, I don't remember all that are there. You will now know for when you ever need to install again.
That's exactly what I was talking about earlier.
You can't disable any service you want with the installer. It has a few options but not all of the stuff I wanted disabled.
The Samba check box a few screens before the advanced screen doesn't appear to do anything.

User avatar
cyrilus31
Posts: 629
Joined: Thu Nov 03, 2016 3:24 pm

Re: Recommended way to disable/enable services?

#8 Post by cyrilus31 »

Time to double check or to use bugtracker ;)

User avatar
srq2625
Posts: 188
Joined: Mon Jan 21, 2019 10:40 am

Re: Recommended way to disable/enable services?

#9 Post by srq2625 »

BV206 wrote: Wed May 08, 2019 3:27 pm bluetooth (computer doesn't have bluetooth)
saned (no scanner)
cups (no printer)
cups-browsed (no network printer)
avahi-daemon (no network printer or file server)
samba (no network file server)
nmbd (no network file server)
smbd (no network file server)
nfs-common (no network file server)
nfs-kernel-server (no network file server)
openvpn (no vpn)
pppd-dns (no dial-up modem)
ModemManager (no dial-up modem)
unattended-upgrades (I manually check for upgrades very day)
Thanks - one more thing to work on "when I have the time". ;)

I can see where disabling some (most) of these would be a goodness in my environment; I also don't have a file server, dial-up modem, or bluetooth.
AsusTek PRIME B450-Plus
AMD Ryzen 7 2700 (8-Core, 16 threads)
Radeon HD 6570/7570/8550 / R5 230
Realtek RTL8111/8168/8411 - driver: r8169
Samsung SSD 860 EVO 500GB
DDR4 3200MHz CL16 2x8GB

User avatar
dreamer
Posts: 738
Joined: Sun Oct 15, 2017 11:34 am

Re: Recommended way to disable/enable services?

#10 Post by dreamer »

BV206 wrote: Wed May 08, 2019 8:46 pm You can't disable any service you want with the installer. It has a few options but not all of the stuff I wanted disabled.
I don't think it's the job of the installer to enable/disable services so I don't change anything. After installation or in a live environment with persistence it's easy to make the changes you want. I recommend that you install the package bum (Boot-Up Manager). It's a GUI application that you can launch from the menu. It takes a while when you launch it for the first time. After that it's faster. It lists running (and not running) services on your system. I prefer it to the "sudo service --status-all" command. It has an Advanced checkbox that will give you some more info for example if the service is related to a deb package and the name of that deb package and a link to the service homepage where you can find more info.

"Off topic": Windows has many management GUIs (from Microsoft and third party), to the point where you hardly have to use the command line. I understand that the CLI is often faster and the way to go if you want to learn a system. But I also think a GUI can provide a better overview and give you info from several commands at the same time. Boot-Up Manager is a bit dated, but as far as I can tell it's fully functional. I hope MX devs package Boot-Up Manager for a Debian Buster based release. Since it's based on sysvinit and not systemd it's unlikely that BUM would suddenly stop working due to low-level breaking changes.

Post Reply

Return to “General”