Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[Solved] Disable autostart of services post install

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
eel
Posts: 4
Joined: 2023-06-07 11:23
Has thanked: 1 time

[Solved] Disable autostart of services post install

#1 Post by eel »

I'm a new Debian user, and I need help removing post-installation autostart for daemons. Is there a configuration that could be used to stop daemons from starting automatically after installation? I can mask the service before installation, but I'm curious whether there's a better way.
Last edited by eel on 2023-06-07 15:49, edited 1 time in total.

User avatar
None1975
df -h | participant
df -h | participant
Posts: 1388
Joined: 2015-11-29 18:23
Location: Russia, Kaliningrad
Has thanked: 45 times
Been thanked: 65 times

Re: [Software] Disable autostart of services post install

#2 Post by None1975 »

Your idea is not good, especially since you are a newbie (not knowing what you stopping or disabling, you can damage the system).

First of all, you should find out what one or another service is responsible for.

To see all running services on a Debian system, use the command:

Code: Select all

systemctl --type=service --state=running
This will show you each active service's name, load, sub-state, and description.

To start a systemd service, executing instructions in the service’s unit file, use the start command. If you are running as a non-root user, you will have to use sudo since this will affect the state of the operating system:

Code: Select all

sudo systemctl start application.service
To restart a running service, you can use the restart command:

Code: Select all

sudo systemctl restart application.service
The above commands are useful for starting or stopping services during the current session. To tell systemd to start services automatically at boot, you must enable them.

To start a service at boot, use the enable command:

Code: Select all

sudo systemctl enable application.service
To disable the service from starting automatically, you can type:

Code: Select all

sudo systemctl disable application.service
Good luck.
OS: Debian 12.4 Bookworm / DE: Enlightenment
Debian Wiki | DontBreakDebian, My config files on github

eel
Posts: 4
Joined: 2023-06-07 11:23
Has thanked: 1 time

Re: [Software] Disable autostart of services post install

#3 Post by eel »

I appreciate the information.

I am new to Debian but have used CentOS for a long time. I have some knowledge of how systemd functions, however the issue I have is that a daemon is running with the default configuration after installing the package. Because several other daemons rely on it and when they're not configured properly, they keep clogging up the journal, I want to stop it. I need to know how to stop a daemon from starting automatically after installation.

User avatar
donald
Debian Developer, Site Admin
Debian Developer, Site Admin
Posts: 1046
Joined: 2021-03-30 20:08
Has thanked: 186 times
Been thanked: 240 times

Re: [Software] Disable autostart of services post install

#4 Post by donald »

@Best_Threads
Typo perfectionish.


"The advice given above is all good, and just because a new message has appeared it does not mean that a problem has arisen, just that a new gremlin hiding in the hardware has been exposed." - FreewheelinFrank

lindi
Debian Developer
Debian Developer
Posts: 412
Joined: 2022-07-12 14:10
Has thanked: 1 time
Been thanked: 77 times

Re: [Software] Disable autostart of services post install

#5 Post by lindi »

The policy-rc.d system is designed for this task but not very well documented.

Random_Troll
Posts: 444
Joined: 2023-02-07 13:35
Been thanked: 105 times

Re: [Software] Disable autostart of services post install

#6 Post by Random_Troll »

If you're using systemd the automatic post-installation enabling of services can be controlled by a .preset file under /etc/systemd/system-preset/, as per systemd.preset(5).

Extant configuration can be viewed in /usr/lib/systemd/system-preset/90-systemd.preset.

This seems to provide similar functionality as policy-rc.d(8) & service-policy.d(5).

EDIT: s/.conf/.preset/
Last edited by Random_Troll on 2023-06-07 19:21, edited 1 time in total.
Jeder nach seinen Fähigkeiten, jedem nach seinen Bedürfnissen.

eel
Posts: 4
Joined: 2023-06-07 11:23
Has thanked: 1 time

Re: [Software] Disable autostart of services post install

#7 Post by eel »

Okay, I have it worked out. Here is a quick rundown:

Installed policyrcd-script-zg2.

Code: Select all

apt-get install policyrcd-script-zg2
Write a script that returns 101 exit code `/usr/local/sbin/daemon-killer.sh`

Code: Select all

#!/bin/bash
exit 101
Make it executable

Code: Select all

chmod 0755 /usr/local/sbin/daemon-killer.sh
Install any daemon package by invoking `apt-get install` as

Code: Select all

POLICYRCD=/usr/local/sbin/daemon-killer.sh apt-get install vsftpd


Create a bash function for persistence in /root/.bashrc.

Code: Select all

stopdaemonmadness () {
POLICYRCD=/usr/local/sbin/daemon-killer.sh apt-get install $1
}
Activate

Code: Select all

source ~/.bashrc

Code: Select all

[Wed Jun 07 20:52:21 root@tangentnetworks /home/tangent] 
# stopdaemonmadness vsftpd
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libpython2-stdlib libpython2.7-minimal libpython2.7-stdlib mpv python-is-python2 python2 python2-minimal python2.7 python2.7-minimal rtmpdump youtube-dl
Use 'apt autoremove' to remove them.
The following NEW packages will be installed:
  vsftpd
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/153 kB of archives.
After this operation, 358 kB of additional disk space will be used.
Preconfiguring packages ...
Selecting previously unselected package vsftpd.
(Reading database ... 202564 files and directories currently installed.)
Preparing to unpack .../vsftpd_3.0.3-12+b1_amd64.deb ...
Unpacking vsftpd (3.0.3-12+b1) ...
Setting up vsftpd (3.0.3-12+b1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/vsftpd.service → /lib/systemd/system/vsftpd.service.
invoke-rc.d: policy-rc.d denied execution of start.
Processing triggers for man-db (2.9.4-2) ...

[Wed Jun 07 20:52:37 root@tangentnetworks /home/tangent] 
# systemctl status vsftpd
● vsftpd.service - vsftpd FTP server
     Loaded: loaded (/lib/systemd/system/vsftpd.service; enabled; vendor preset: enabled)
     Active: inactive (dead)

Jun 07 20:24:29 tangentnetworks systemd[1]: Starting vsftpd FTP server...
Jun 07 20:24:29 tangentnetworks systemd[1]: Started vsftpd FTP server.
Jun 07 20:25:02 tangentnetworks systemd[1]: Stopping vsftpd FTP server...
Jun 07 20:25:02 tangentnetworks systemd[1]: vsftpd.service: Succeeded.
Jun 07 20:25:02 tangentnetworks systemd[1]: Stopped vsftpd FTP server.

eel
Posts: 4
Joined: 2023-06-07 11:23
Has thanked: 1 time

Re: [Software] Disable autostart of services post install

#8 Post by eel »

Random_Troll wrote: 2023-06-07 15:19 If you're using systemd the automatic post-installation enabling of services can be controlled by a .conf file under /etc/systemd/system-preset/, as per systemd.preset(5).

Extant configuration can be viewed in /usr/lib/systemd/system-preset/90-systemd.preset.

This seems to provide similar functionality as policy-rc.d(8) & service-policy.d(5).
Thank you. Your concept is more sophisticated than the one I had.

Post Reply