How to uninstall Libreoffice on Ubuntu in terminal?

I’m running Ubuntu without desktop. I have only terminal access to my Ubuntu server. I installed LibreOffice 4.1.0 for pdf generating. I installed LO 4.1.0 by following the readme file using dpkg -i *.deb. Now I want to upgrade to 4.1.1, so now I want to uninstall the previous version first. But I don’t see from any documentation how to do it.

If I can manage the install/uninstall using apt-get, that would be the best. However, I get a very old version of LibreOffice using Ubuntu’s default apt-get.

What is your Ubuntu version?

My friend, you must use

# sudo apt-get remove --purge libreoffice*.*

Above cmd didn’t work for me but the following one did

sudo apt-get -f install

I suggest to uninstall libreoffice currently installed on system:

  1. If installed from official repository:
sudo apt-get remove --purge libreoffice*

  1. If installed from deb package:
sudo dpkg -P libreoffice*

Note: If you are not sure how you installed, you can execute both commands.

Never install LibreOffice from LibreOffice download page using deb package, because this packages are not optimized for Ubuntu, but are common packages to all Linux distributions. I suggest to install LibreOffice from Ubuntu PPA.

See my answer how to add LibreOffice 4.1 Ubuntu PPA:

Thanks for the PPA information, which is exactly what I have been struggling to look for. However, I still cannot remove it using the command line. Here’s what I got:

# sudo dpkg -P libreoffice
dpkg: warning: ignoring request to remove libreoffice which isn't installed