20

How do I completely rip-out smb / samba from my Ubuntu 11.10 machine?

How do I, afterwards, reinstall it cleanly?

UPDATE: My goal is to rip out any functionality related to Windows SMB from my desktop and do a clean re-install of these components. See this question for some background.

jldupont
  • 861

6 Answers6

27

So, for the server, from the Terminal:

sudo apt-get remove --purge samba
sudo apt-get install samba

But, if you are having client problems, it would be more like:

sudo apt-get remove --purge smbclient libsmbclient
sudo apt-get install smbclient libsmbclient

Update:

Note that this answer only applies to Ubuntu 11.10! More recent Ubuntus will probably remove useful software with the apt remove command, so be sure to check what is being removed and if needed "cherrypick" packages in synaptic or similar.

isync
  • 664
dpb
  • 7,209
15

A easier way to remove Samba that is simpler and cleaner.

sudo apt-get autoremove samba samba-common

This step uses the autoremove to remove the package.

sudo apt-get purge samba samba-common

This step cleans any configuration file you may have

fideli
  • 103
cyeudoxus
  • 151
3

In Ubuntu 18.04/20.04:

remove:

sudo apt -y remove --purge samba samba-common cifs-utils smbclient
sudo rm -rf /var/cache/samba /etc/samba /run/samba /var/lib/samba /var/log/samba

install:

sudo apt -y install samba samba-common smbclient cifs-utils winbind

source: Samba full audit

acgbox
  • 2,367
0

This was not enough here. I got this message:

Load smb config files from /etc/samba/smb.conf Error loading services. dpkg: Fehler beim Bearbeiten des Paketes samba-common-bin (--configure): »installiertes samba-common-bin-Skript des Paketes post-installation«-Unterprozess gab den Fehlerwe rt 1 zurück Fehler traten auf beim Bearbeiten von: samba-common-bin E: Sub-process /usr/bin/dpkg returned an error code (1)

I needed to reset the config 1st, before apt remove --purge worked again.

If install/upgrade will fail. To recover, please try:

sudo cp /usr/share/samba/smb.conf /etc/samba/smb.conf

After reset of smb.conf, purge worked.

0

These solutions all relay on the system booting. But what do you do if your system is not booting because of samba?

If you are stuck in recovery mode, IE the rescue disk. apt-get does not always work, in fact it will get you a seg fault in a recovery shell, atleast on Ubuntu from what I've seen. To get around that, you can use dpkg --purge --force-all samba and also for common and winbind if the system still wont boot.

Remember if you are in the recorvery mode shell, do not use sudo, because that will cause a seg fault. Just use the commands as you would if you were in as root.

But I have had Samba cause a system to stop booting, and this is how I was able to rip samba out, and then do a clean install after I got the system booting all the way up again. Once it's booted all the way up, go through and do the sudo apt-get remove --purge samba samba-common command to make sure everything has been removed. Unfortunately, you may also have to manually delete some items, because dpkg does not always delete startup scripts and other items the binary creates. This is what I've had to do, to thoroughly remove samba, when I couldn't get the system to boot.

I hope this helps someone who was stuck in the same situation as me.

0

I recently installed Ubuntu 17.04 under VirtualBox on a Windows 7 host and I needed to access files on the host. I'm fairly new to Linux so I thought I needed samba to access those shares. As mentioned above by dpb, I was having client problems. It turned out all I really needed to do was remove samba. Having Ubuntu 17.04 meant I had to re-install cifs-utils, not smbclient in order to get client functionality back:

sudo apt-get install cifs-utils

After reboot, all my Windows network shares were accessible and client issues resolved.

wjandrea
  • 14,504
wgengland
  • 1
  • 2