How do I completely remove Samba?

  • 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.

  • dpb

    dpb Correct answer

    9 years ago

    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.

    After I have completed both "server" and "client" components, how come Nautilus still shows "Browse Network" and "Windows Network" then?

    Is there a relationship with Gnome/GVFS somewhere along the lines? How do I get rid / re-install that too?

    Even after your proposed steps, I still can do "mount -t cifs". How do I completely get rid of smb stuff and do a clean install?

    `apt-get purge samba` does the same.

    The reason that you can still mount a cifs filesystem even after removing samba is that the cifs kernel module is not a part of any samba package. It is included in the kernel. That module has client support only for accessing cifs shares on a network. One does not need samba to access shares. But to create them samba needs to be installed.

    perhaps a 'rmmod cifs' is in order

    @jldupont, I'd recommend sticking with the original question. I'll go over there and answer.

    `sudo apt-get remove --purge smbclient libsmbclient` command is removing useful softwares like `gvfs-backends* libsmbclient* python3-smbc* software-center* system-config-printer-common* system-config-printer-gnome* ubuntu-desktop* vlc-plugin-samba*` so vote down

    @edwardtorvalds, this answer was in 2011 and asked specifically about 11.10 which was end of life 4 years ago. You tried on 11.10 and it didn't work?

  • 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

    This commands are completes total removal.

  • 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.

  • 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.

  • In Ubuntu 18.04:

    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
    

License under CC-BY-SA with attribution


Content dated before 6/26/2020 9:53 AM

Tags used