In Debian-based systems (like Lenny in this case), runlevels determine which services are started during system initialization. The traditional SysV init system uses runlevels 0-6, with:
0 - Halt 1 - Single user mode 2-5 - Multi-user modes (varies by distribution) 6 - Reboot
The OP correctly identified an issue with using update-rc.d foo stop 3 .
- this creates a stop script that would kill the service whenever entering runlevel 3, rather than preventing it from starting in the first place.
To completely prevent a service from starting at any runlevel, use:
update-rc.d -f foo remove
This removes all symbolic links in all runlevel directories, effectively preventing the service from starting automatically at any runlevel.
For more granular control, you can manually remove specific runlevel links:
ls /etc/rc*.d/*foo* # Then remove relevant links like: rm /etc/rc3.d/S*foo*
After making changes, verify with:
ls -l /etc/rc*.d/*foo* # Or using sysv-rc-conf (if installed): sysv-rc-conf --list foo
To ensure changes persist across package updates:
echo 'manual' > /etc/init/foo.override # For upstart systems # Or for systemd (though not applicable to Lenny): systemctl disable foo.service
When managing services in Debian Linux (or other SysV-init systems), you might encounter situations where you need to completely prevent a service from starting at any runlevel. The common update-rc.d
approach has some limitations that might not match your requirements.
# This creates stop symlinks at specified runlevels
update-rc.d foo stop 3 4 5
The standard method using update-rc.d
creates symbolic links that execute stop commands during runlevel transitions. This means:
- The service might still start temporarily during boot
- It adds unnecessary stop operations to the init sequence
- Doesn't actually prevent the service from being started manually
To completely disable a service across all runlevels:
# First check current runlevel configuration
ls -l /etc/rc*.d/*foo*
# Then remove all symlinks (Debian/Ubuntu method)
update-rc.d -f foo remove
# Alternative direct approach
rm -f /etc/rc*.d/[SK]??foo
For modern systems with both SysV and systemd:
# If using systemd as well
systemctl disable foo.service
systemctl mask foo.service
# Prevent manual starts by changing the init script
chmod -x /etc/init.d/foo
After making changes:
# Verify no symlinks remain
find /etc/rc*.d -name '*foo*'
# Check service status
service foo status
# or for systemd
systemctl status foo
Remember that some services might be started by other mechanisms (cron, other services, etc.), so you might need additional configuration depending on your specific case.