43

How can I disable avahi-daemon and can you explain to me how it runs if it appears as a service but it itsn't in rcN.d?


You can stop reading here. In fact, please do unless you want to TEACH a noob some Ubuntu. The question above should be clear enough to be answered. The rest is just me calling out for some more structured way of finding one's way around Ubuntu. I can more or less use other "UNIX-like" systems.

I am a beginner so if I act nonsensically, consider me your daily WTF but do help me improve, please.

At every boot, /sbin/init seems to be launching a process called avahi-daemon

# initctl list | grep avahi
avahi-daemon start/running, process 1280

as user avahi

# id avahi
uid=107(avahi) gid=118(avahi) groups=118(avahi)

a ps -efww ef shows 2 processes active, both called avahi-daemon, and the PPID of the first avahi-daemon is indeed 1, the second process is just a child of the first. The PPID = 1 is what makes me think this was auto-started.


Optionally:

I don't really know how to check properly what gets executed at system startup, thinking about it.

Is this the way to get a list of services that run at startup? initctl list | sort


anyway, I seem to be able to temporarily stop this "service" through this command:

service avahi-daemon stop

or indeed this command

/etc/init.d/avahi-daemon stop

directly, which is what this /usr/sbin/service seems to be using:

env -i LANG="$LANG" PATH="$PATH" TERM="$TERM" "$SERVICEDIR/$SERVICE"

When launched, the script reminds me that I am controlling an "Upstart" service, and that I should use the simpler invocation stop avahi-daemon. I guess I will need to learn about Upstart but for now, all I need to learn is this:

how do I disable services in Ubuntu?

Here is what I tried (this should be the proper way to do it, or is it not?):

update-rc.d avahi-daemon disable

but it complains:

System start/stop links for /etc/init.d/avahi-daemon do not exist

so I went hunting for the path to the binary:

# Let me know if there is a better way to get the path above
readlink "/proc/$(echo `ps --no-headers -o pid -C avahi-daemon | head -n 1`)/exe"

which is this:

/usr/sbin/avahi-daemon

and anything that could be considered an "executable file" in etc:

find /etc -type f -name '*avahi*' -perm -u+x

thinking I would find startup scripts in /etc/rcN.d. I found other things instead:

/etc/dhcp/dhclient-exit-hooks.d/zzz_avahi-autoipd
/etc/dhcp/dhclient-enter-hooks.d/avahi-autoipd
/etc/resolvconf/update-libc.d/avahi-daemon
/etc/network/if-up.d/avahi-autoipd
/etc/network/if-up.d/avahi-daemon
/etc/network/if-down.d/avahi-autoipd
/etc/avahi/avahi-autoipd.action

seems like this avahi-daemon thing is being launched on network state changes? Is there a better way to hunt down binaries automatically started on a system?

I would have normally obliterated the symlinks in the various rc{3,5}.d at this stage but now I am not too sure. What exactly starts this beast? How to disable it without apt-get remove or apt-get purge?

It does not have too many resources open, as far as I can see:

lsof -p $(echo `ps --no-headers -o pid -C avahi-daemon | head -n 1`)

nor does it use too many CPU cycles, based on a quick glance at htop.

I wrote this one-liner to see if it goes funky on CPU util over a period of one minute, and it never does, but let me know if there are better ways to check that:

for i in {1..59}; do ps -p $(echo `ps --no-headers -o pid -C avahi-daemon | head -n 1`) --no-headers -o pcpu; sleep 1; done
Robottinosino
  • 1,221
  • 3
  • 13
  • 18

9 Answers9

27
sudo systemctl disable avahi-daemon

worked for me on Ubuntu Gnome 15.10

Databits
  • 271
  • 3
  • 2
  • 2
    You can also run "sudo systemctl stop avahi-daemon" to stop it immediately. This is the real answer to the question. – EnzoR Feb 25 '18 at 18:44
23

Upstart startup scripts live in /etc/init, where you can find avahi-daemon.conf. All things listed in initctl list match to scripts in /etc/init, and they are not executable, thus your find missed them.

To disable a Upstart controlled service, see Upstart cookbook on disabling services: either add # to start on line, or use override files (example: sudo sh -c "echo manual > /etc/init/avahi-daemon.override").

Tuminoid
  • 3,942
  • 1
  • 21
  • 28
11

I found that even if I stop avahi-daemon (and avahi-daemon.socket), Firefox always restarts it. However, this works, and disables this annoying daemon permanently:

apt-get remove avahi-daemon
edwinksl
  • 23,569
  • 16
  • 74
  • 100
Peter
  • 111
  • 1
  • 2
  • What does firefox have anything to do with this question? – Mxx Oct 15 '16 at 14:48
  • 2
    @Mxx firefox just triggers the socket which restarts Avahi. I had to uninstall it as well in order to make wget and curl not use it. – qwertzguy Feb 07 '17 at 00:12
  • drastic solution, but fast and working one! – andilabs Sep 06 '17 at 13:43
  • Read all answers, considered this one a joke, tried the other ones to no avail, finally used this one and upvoted it – golimar Nov 05 '19 at 08:54
  • And to be completely thorough, `sudo DEBIAN_FRONTEND=noninteractive apt-get purge --auto-remove avahi-daemon` – volvox Jun 06 '20 at 20:16
  • I've had problems with Avahi since Ubuntu 17.10 just trashing my wifi and disabling it requiring a reboot to get wifi back online. Just installed Lubuntu 18.04.5LTS on another laptop, and it began messing with my wifi on that computer too... best to just remove it! I also believe it can be a security risk allowing unauthorized computers to mess with my wifi. Occasionally I'd have two (2) sets of wifi bars in the panel - weird! Other times it would drop wifi, reload, drop again and not be able to reload without rebooting. I have no use for it at all... – The MAJOR Apr 25 '21 at 14:00
5

You might not need to stop it from starting up when PC boots, but maybe prevent it from respawn as it does, when you kill it.

So, just comment out the respawn in /etc/init/avahi-daemon.conf

Killing that process always failed, so couldn't get airmon-ng check to pass. Commenting out the respawning, it kills and never comes back hunting me.

KhoPhi
  • 1,878
  • 1
  • 18
  • 30
4

You need to mask the socket to prevent applications starting avahi-daemon:

systemctl mask avahi-daemon.socket
systemctl disable avahi-daemon
systemctl stop avahi-daemon
Stuart Cardall
  • 329
  • 2
  • 7
1

service avahi-daemon stop

Use this. Works wonders.

Then use airmon-ng check wlo1 to check overlapping services. U should find none.

  • Works once. Next time you boot avahi starts again. Is this what you want? No I think, because question was how to disable avahi (to start). use above mentioned 'sudo systemctl disable avahi-daemon' to disable avahi without removing it or 'sudo apt-get remove avahi-daemon' to remove avahi permanently, so it can't start. – Reijo Korhonen May 31 '21 at 17:14
0

Just used this and works fine on Ubuntu 16.04

service avahi-daemon stop


I know the OP uses this line, but to summarize for who is searching for a simple command (like myself).

jpenna
  • 150
  • 1
  • 8
0

Just purge it. Or disable it in rc3.d, rc4.d , and rc5.d So as su / root

apt-get purge avahi-daemon

yes

Than it should be off your system. Check your /etc/rc3.d and others and it should be gone from startup.

Don't use systemd for disable best way is to remove or change the runscript to K instead of S in the run layers.

Apple
  • 1
0

How about using

sysv-rc-conf

For these thing? It's very handy!

(i.e. first install it with apt-get and then run it as sudo)

El Sampsa
  • 111
  • 4