LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Disabling unnecessary startup services (https://www.linuxquestions.org/questions/linux-newbie-8/disabling-unnecessary-startup-services-850426/)

sdgh1 12-15-2010 11:27 AM

Disabling unnecessary startup services
 
Hello,

In order to preserve resources and to have more secure machine I want to disable services which are of no use to me. But being relatively new to Linux I want to make sure I'm disabling those really unnecessary and that my actions wont have a negative impact on overall system health / usability. All comments, suggestions and constructive critique is welcome and appreciated!

Below is the output from sysv-rc-conf --list

Code:

acpi-support 1:off      2:on    3:on    4:on    5:on
acpid     
alsa-mixer-s
anacron   
apparmor    S:on
apport     
atd       
avahi-daemon
binfmt-suppo 2:on      3:on    4:on    5:on
bluetooth    0:off      1:off  2:on    3:on    4:on    5:on    6:off
bootlogd   
brltty      S:on
console-setu
cron       
cryptdisks  0:on      6:on
cryptdisks-e 0:on      6:on
cryptdisks-e
cryptdisks-u
cups       
dbus       
dmesg     
dns-clean    1:on      2:on    3:on    4:on    5:on
ecryptfs-uti
ecryptfs-uti
failsafe-x 
fancontrol  2:on      3:on    4:on    5:on
gdm       
grub-common  2:on      3:on    4:on    5:on
halt        0:on
hostname   
hwclock   
hwclock-save
irqbalance 
kerneloops  1:off      2:on    3:on    4:on    5:on
killprocs    1:on
lm-sensors  S:on
module-init-
network-inte
network-inte
network-mana
networking  0:on      6:on
ondemand    2:on      3:on    4:on    5:on
pcmciautils  S:on
plymouth   
plymouth-log
plymouth-spl
plymouth-sto
pppd-dns    1:on      2:on    3:on    4:on    5:on
procps     
pulseaudio  1:off      2:on    3:on    4:on    5:on
rc.local    2:on      3:on    4:on    5:on
reboot      6:on
rsync        2:on      3:on    4:on    5:on
rsyslog   
saned        1:off      2:on    3:on    4:on    5:on
screen-clean
sendsigs    0:on      6:on
single      1:on
speech-dispa 1:off      2:on    3:on    4:on    5:on
stop-bootlog
stop-bootlog
sudo        2:on      3:on    4:on    5:on
udev       
udev-finish
udevmonitor
udevtrigger
ufw       
umountfs    0:on      6:on
umountroot  0:on      6:on
unattended-u 0:on      6:on
urandom      0:on      6:on    S:on
x11-common  S:on

Now, as far as I understand services which sysv-rc-conf listed as not being on or off at any runtime level are started by upstart at every boot using scripts from /etc/init/. So in order to disable any of those I need to remove or rename appropriate .conf file from /etc/init/ - Am I correct on this one?

I'm running Ubuntu 10.10 on a laptop which means that things like acpi-support, pcpid or lm_sensors I will want to have. I'm not using dail-up so I should have no need for atd and pppd-dns. To list other services I'm planing on getting rid of:
anacron, bluetooth, brltty, cups, rsync, saned, speech-dispatcher

I'm not sure what to do with avahi-deamon - I'm not using any network shares, at least currently, so it should be safe to turn it off.

Services I'm not quite sure what to do with are as follow:
dns-clean, hostname, screen-clean

Finally, services I'm planing on leaving on:
acpi-support, acpid, alsa-mixer-save, apparmor, apport, binfmt-support, bootlogd, console-setup, cron, cryptdisks, cryptdisks-enable, cryptdisks-udev, dbus, dmesg, ecryptfs-utils-restore, ecryptfs-utils-save, failsafe-x, fancontrol, gdm, grub-common, halt, hwclock, hwclock-save, irqbalance, kerneloops, killprocs, lm-sensors, module-init-tools, network-interface, network-interface-security, network-manager, networking, ondemand, pcmciautils, plymouth, plymouth-log, plymouth-spl, plymouth-sto, procps, pulseaudio, rc.local, reboot, rsyslog, saned, screen-clean, sendsigs, single, stop-bootlog, stop-bootlog, sudo, udev, udev-finish, udevmonitor, udevtrigger, ufw, umountfs, umountroot, unattended-u, urandom, x11-common

I know, I'm leaving plymouth - but it just looks gorgeous ;-)

Corrections and suggestions anyone?


Tom

barriehie 12-15-2010 11:53 AM

The command you're looking for to enable/disable boot scripts is update-rc.d. What I do to disable a service is rename the /etc/init.d/file_name to /etc/init.d/file_name.bak and then run
Code:

update-rc.d file_name remove
to remove the init/kill scripts.

HTH,

Tinkster 12-15-2010 11:56 AM

Hi, welcome to LQ!

atd has nothing to do with dial-up; it allows you to
run commands as one-offs at a given time. You also
shouldn't really disable anacron - some system maintenance
tasks may rely on it (not that I know much about Ubuntus
inner workings).

sdgh1 12-15-2010 12:15 PM

Quote:

The command you're looking for to enable/disable boot scripts is update-rc.d.
Thanks for explaining that! Your instructions combined with man should give me all the knowledge I need to disable unwanted services.

@Tinkster

You're right about atd and anacron! From man pages:
Quote:

atd - run jobs queued for later execution
And as for anacron I went and had a peak at /etc/anacrontab - it seems that it's taking care of tasks that weren't completed by cron, at least to my understanding. So indeed, I do want to have those two enabled. Thanks!

barriehie 12-15-2010 01:31 PM

Be careful when disabling things! You could end of with a hung machine at boot. :(

sdgh1 12-15-2010 05:07 PM

Quote:

Originally Posted by barriehie (Post 4192655)
Be careful when disabling things! You could end of with a hung machine at boot. :(

Ha! I'm well aware of it and careful I shall be, but there is no fun without a little bit of risk ;-) Worst come to worst I did a backup of everything.

For now I have disabled only avahi-demon, bluetooth, brltty, cups / cupsd and saned. Printing daemon and avahi were a bit of a pain - I wasn't able to get rid of them using update-rc.d. What did the trick for me was to rename their files in /etc/init/. Now they are no more!

In the course of googling form more information about couple of processes I came across this little, precious gem - bootchart. Now, my booting time is roughly 30 seconds and I'm quite happy with this, tweaking things to get an extra second or two doesn't appeal to me. But having more memory available is quite tempting.

My next target is getty - I'm not using terminal much and so I want to changing the number of available terminals from four to only two or even one. Any idea how I should get around to do that? I'm still looking for informations about that but this time google don't seems to be on my side...

barriehie 12-15-2010 05:33 PM

Quote:

Originally Posted by sdgh1 (Post 4192871)
...muted...
My next target is getty - I'm not using terminal much and so I want to changing the number of available terminals from four to only two or even one. Any idea how I should get around to do that? I'm still looking for informations about that but this time google don't seems to be on my side...

Yes, you'll want to edit /etc/inittab. Here you can see the section from mine where 6 are enabled. Just comment, put a # sign, at the beginning of the line.
Code:

# /sbin/getty invocations for the runlevels.
#
# The "id" field MUST be the same as the last
# characters of the device (after "tty").
#
# Format:
#  <id>:<runlevels>:<action>:<process>
#
# Note that on most Debian systems tty7 is used by the X Window System,
# so if you want to add more getty's go ahead but skip tty7 if you run X.
#
1:2345:respawn:/sbin/getty 38400 tty1
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:respawn:/sbin/getty 38400 tty5
6:23:respawn:/sbin/getty 38400 tty6


sdgh1 12-15-2010 05:43 PM

Just rebooted and everything seems to be still working! I did have six as well, now it just two. But I done it in a different way - I went to /etc/init/ and appended _bak to filenames of last four tty's.

For now that the end for me - I need to read some more about other services before I will attempt to disable them. Suggestions where should I start are more than welcome!

barriehie 12-15-2010 06:02 PM

1 Attachment(s)
Quote:

Originally Posted by sdgh1 (Post 4192901)
Just rebooted and everything seems to be still working! I did have six as well, now it just two. But I done it in a different way - I went to /etc/init/ and appended _bak to filenames of last four tty's.

For now that the end for me - I need to read some more about other services before I will attempt to disable them. Suggestions where should I start are more than welcome!

While that method 'works' the system is still trying to find a file that doesn't exist, UNLESS you removed the init scripts with update-rc.d. If you want minimal services install fluxbox or the like.
Code:

03:37:08 /home/barrie $ > ps -u barrie
  PID TTY          TIME CMD
 3455 pts/0    00:00:00 bash
 3598 pts/1    00:00:00 bash
 3643 ?        00:00:01 fluxbox
 3691 ?        00:00:00 ssh-agent
 3694 ?        00:00:00 dbus-daemon
 3695 ?        00:00:00 dbus-launch
 3698 ?        00:00:00 xscreensaver
 3699 ?        00:00:00 conky
 3724 ?        00:00:06 mrxvt
 3725 pts/2    00:00:00 bash
 3727 ?        00:00:00 icedove
 3739 ?        00:00:00 run-mozilla.sh
 3744 ?        00:00:08 icedove-bin
 3747 ?        00:00:00 gconfd-2
 3763 ?        00:01:37 firefox-bin
 4235 pts/2    00:00:00 ps
03:57:43 /home/barrie $ >


sdgh1 12-15-2010 08:05 PM

1 Attachment(s)
OK, I got rid of the following: avahi-daemon, bluetooth, brltty, cups, dns-clean, pppd-dns, rsync, saned, speech-dispatcher and I'm down to two tty's. I'm planing on removing unattended-updates as well but after setting up cron job to take over it's function.

@barriehie

I went with your advice and used update-rc.d to remove all the links, thanks again. Fluxbox looks interesting but (ashamed) I have to admit that I like visual side of Ubuntu. This "frantic" disabling of services is a learning experience for me - what those things are doing and what will happen when I will switch them off. And there is security / maintenance approach - less services running, less chances for something to go funny ;-)

I'm attaching graph from bootchart - if anyone will have any suggestions as to what (and why) I can still disable I will be grateful.

tommcd 12-15-2010 08:15 PM

You can use sysv-rc-conf directly to enable or disable services. That is what it is for. You don't need to mess with anything in /etc/init/. See this tutorial on sysv-rc.conf:
http://ubuntuforums.org/showthread.php?t=89491
It is a bit out of date, but it does go into detail on how to use sysv-rc-conf. It is a handy tool for enabling or disabling services.

There is also an option under: system > administration > startup_services (or it may be: system > preferences > startup_services) for enabling and disabling may things from starting automatically.

sdgh1 12-15-2010 08:33 PM

Yeah, I know about sysv-rc-conf but you can't disable couple of things with it completely, ex. avahi-daemon or cups. If you will have a look here you will know what I was messing with /etc/init in the first place. As for using Startup Applications from the menu - it's OK to start with but it have just bare basic. What I want to do is to learn a bit about every process which is started - what they are there for and what can be done with them.

This tutorial you have mentioned is actually a reason for all that!

barriehie 12-16-2010 01:29 AM

I've been using fluxbox long enought that a 'regular' desktop is rather weird! I can go with the CLI and not much in the way of a drop down menu!

Axelman0 12-16-2010 02:54 AM

I'm not sure how editable the /etc/init/rc.local file is in Ubuntu, but Arch Linux uses a somewhat similarly named /etc/rc.conf file. Here is mine so you can see what the (almost) bare minimums are. Keep in mind I'm not running a gui or even pulseaudio.

Code:

#
# /etc/rc.conf - Main Configuration for Arch Linux
#

# -----------------------------------------------------------------------
# LOCALIZATION
# -----------------------------------------------------------------------
#
# LOCALE: available languages can be listed with the 'locale -a' command
# HARDWARECLOCK: set to "UTC" or "localtime", any other value will result
#  in the hardware clock being left untouched (useful for virtualization)
# TIMEZONE: timezones are found in /usr/share/zoneinfo
# KEYMAP: keymaps are found in /usr/share/kbd/keymaps
# CONSOLEFONT: found in /usr/share/kbd/consolefonts (only needed for non-US)
# CONSOLEMAP: found in /usr/share/kbd/consoletrans
# USECOLOR: use ANSI color sequences in startup messages
#
LOCALE="en_US.UTF-8"
HARDWARECLOCK="UTC"
TIMEZONE="America/Chicago"
KEYMAP="us"
CONSOLEFONT="ter-u32n.psf.gz"
CONSOLEMAP=
USECOLOR="yes"

# -----------------------------------------------------------------------
# HARDWARE
# -----------------------------------------------------------------------
#
# MOD_AUTOLOAD: Allow autoloading of modules at boot and when needed
# MOD_BLACKLIST: Prevent udev from loading these modules
# MODULES: Modules to load at boot-up. Prefix with a ! to blacklist.
#
# NOTE: Use of 'MOD_BLACKLIST' is deprecated. Please use ! in the MODULES array.
#
MOD_AUTOLOAD="yes"
#MOD_BLACKLIST=() #deprecated
MODULES=()

# Scan for LVM volume groups at startup, required if you use LVM
USELVM="no"

# -----------------------------------------------------------------------
# NETWORKING
# -----------------------------------------------------------------------
#
# HOSTNAME: Hostname of machine. Should also be put in /etc/hosts
#
HOSTNAME="Archer1"

# Use 'ifconfig -a' or 'ls /sys/class/net/' to see all available interfaces.
#
# Interfaces to start at boot-up (in this order)
# Declare each interface then list in INTERFACES
#  - prefix an entry in INTERFACES with a ! to disable it
#  - no hyphens in your interface names - Bash doesn't like it
#
# DHCP:    Set your interface to "dhcp" (wlan0="dhcp")
# Wireless: See network profiles below
#

#Static IP example
#eth0="eth0 192.168.0.2 netmask 255.255.255.0 broadcast 192.168.0.255"
#wlan0="dhcp"

INTERFACES=()

# Routes to start at boot-up (in this order)
# Declare each route then list in ROUTES
#  - prefix an entry in ROUTES with a ! to disable it
#
gateway="default gw 192.168.0.1"
ROUTES=(!gateway)
 
# Setting this to "yes" will skip network shutdown.
# This is required if your root device is on NFS.
NETWORK_PERSIST="no"

# Enable these network profiles at boot-up.  These are only useful
# if you happen to need multiple network configurations (ie, laptop users)
#  - set to 'menu' to present a menu during boot-up (dialog package required)
#  - prefix an entry with a ! to disable it
#
# Network profiles are found in /etc/network.d
#
# This now requires the netcfg package
#
#NETWORKS=(main)

# -----------------------------------------------------------------------
# DAEMONS
# -----------------------------------------------------------------------
#
# Daemons to start at boot-up (in this order)
#  - prefix a daemon with a ! to disable it
#  - prefix a daemon with a @ to start it up in the background
#
DAEMONS=(syslog-ng network netfs crond alsa)

If you want to trim some fat I'd suggest you look into the various wireless modules and blacklist the ones that you do not need. My wireless card on my old laptop actually would not work until I added "!b44" to the modules in the 'HARDWARE' section. It was getting in the way of the b43legacy driver that I needed. Test your computer by removing the modules with
Code:

modprobe -r <modulename>
before you mess with any config files though. You can use
Code:

lsmod
to list all of the modules that you have loaded, and if you're looking for something specific you can pipe it to grep:
Code:

lsmod|grep <search string>
.


All times are GMT -5. The time now is 03:14 PM.