Remove Tomcat from Linux | Uninstall Tomcat Ubuntu

Last updated: October 26, 2022 | Bobbin Zachariah

Apache Tomcat or simply Tomcat (formerly it was also known as Jakarta Tomcat) is an open-source web server and servlet container developed by the Apache Software Foundation (ASF). Tomcat can be installed on CentOS Stream /Redhat machine either using yum or from the source file. However, in this tutorial, we will see, how we can uninstall/remove tomcat from the Linux machine.

In order to remove tomcat from your machine, the first thing you need to check is how this package got installed on your server.

Removal of Tomcat installation through package manager

Using yum

Suppose, you have installed tomcat 5 or tomcat 9 using yum package manager, then the default tomcat configurations can be found at “/etc/tomcat5” and “/usr/share/tomcat5”. You can find the tomcat packages using the following command:

rpm -qa | grep tomcat

Now, you can proceed with the uninstallation of the listed packages using “yum” as follows:

yum remove tomcat5
yum remove tomcat5-webapps
yum remove tomcat5-admin-webapps

Continue this for the other packages. Packages such as tomcat5-servelet may have many dependencies including open office. So, if you want to remove the packages without removing the dependencies, you need to use the command “rpm” as follows:

rpm -e package_name -nodeps

After removing the packages, you need to remove the tomcat directories too:

rm -rf /etc/tomcat5
rm -rf /usr/share/tomcat5

Using Apt

On Ubuntu to remove system and config files run below commands

sudo apt remove --purge tomcat9 tomcat9-docs
sudo apt autoremove
sudo apt autoclean

You can locate and manually delete the remaining files if any exists.

sudo apt install locate && sudo updatedb
locate tomcat

Using Apt-get

To remove just the tomcat9 package

sudo apt-get remove tomcat7

To remove tomcat9 package and its dependent packages

sudo apt-get remove --auto-remove tomcat9

This will delete all local/config files and can't be restored

sudo apt-get purge tomcat9
sudo apt-get purge --auto-remove tomcat9

Removal of Tomcat source file installation

In this case, you need to stop tomcat and remove all the binaries from the server.

1. To stop tomcat

Let's first stop the service.


2. To remove tomcat binaries and folders

Remove all occurrences of tomcat binary files and folders from the below locations

rm -f /usr/sbin/startomcat
rm -f /usr/sbin/stoptomcat
rm -Rf /usr/local/jakarta

3. To remove from 'chkservd'

Stop chkservd and remove tomcat from there if it is configured.

service chkservd stop
cd /etc/chkserv.d
rm -Rf tomcat
cd /var/run/chkservd
rm -Rf Tomcat_JSP
service chkservd start

4. To remove Tomcat Connector configuration from Apache web server

Remove all mod_jk lines from httpd.conf, including addmodule, loadmodule, and include lines.


In this guide, we learned how to completely remove tomcat from Linux distributions such as Ubuntu.



Please add comments below to provide the author your ideas, appreciation and feedback.

Leave a Reply

Leave a Comment