Uninstall Apache Tomcat server in Ubuntu a step by step guide. Quick fact: removing Tomcat cleanly ensures no lingering services or files hogging system resources. In this guide, you’ll get a practical, veteran-tech approach to completely removing Tomcat from an Ubuntu machine, whether you installed it manually or via a package manager. We’ll cover commands, cleanup tips, and some verification steps so you’re not left guessing.
- Quick start overview
- Prerequisites
- Uninstall methods manual install vs package manager
- Cleanup remaining files and user accounts
- Verification and post-uninstall checks
- Common issues and troubleshooting
- Useful resources
Introduction: what you’ll learn and why it matters
Uninstall Apache Tomcat server in Ubuntu a step by step guide. If you’ve decided Tomcat isn’t needed on a server anymore, you want to make sure you remove both the software and any associated users, services, and files. Leftover artifacts can waste disk space, pose security risks, and complicate future installations.
- Quick facts:
- Tomcat can be installed in multiple ways: from a tar.gz binary, via apt, or as part of a larger stack.
- A clean uninstall includes stopping services, removing startup scripts, deleting user accounts if created for Tomcat, and deleting the Tomcat installation directory.
- Always back up configuration files you might want to reuse before removal.
Useful URLs and Resources plain text
- Oracle Tomcat Documentation – tomcat.apache.org
- Ubuntu Server Guide – ubuntu.com/server/docs
- Apache Tomcat 9/10/10.1/11 Docs – tomcat.apache.org/tomcat-
- Debian/Ubuntu System Administrator’s Guide – wiki.debian.org
- Stack Overflow Tomcat uninstall – stackoverflow.com
Prerequisites
- You have sudo access on the Ubuntu server.
- You know whether Tomcat was installed via a package manager apt or manually from a binary tarball.
- You have a plan for what to do with config files you might want to keep.
Uninstall Tomcat installed via package manager apt
If you installed Tomcat using apt or a package from the Ubuntu repositories, follow these steps:
- Stop the Tomcat service
- sudo systemctl stop tomcat
- If your service name is different like tomcat9 or tomcat10, adjust accordingly:
- sudo systemctl stop tomcat9
- sudo systemctl stop tomcat10
- Disable the service so it doesn’t start on boot
- sudo systemctl disable tomcat
- Or for a specific version:
- sudo systemctl disable tomcat9
- sudo systemctl disable tomcat10
- Remove the Tomcat package
- Find installed Tomcat packages:
- dpkg -l | grep tomcat
- Remove the packages:
- sudo apt-get purge tomcat9 tomcat9-common
- sudo apt-get purge tomcat10
- If you see tomcat9-admin or tomcat9-user, purge those too.
- Clean up dependencies that are no longer needed:
- sudo apt-get autoremove
- sudo apt-get clean
- Remove Tomcat user and group if created by the package
- sudo deluser –remove-home tomcat
- sudo delgroup tomcat
- Remove any residual configuration or log directories check common paths
- sudo rm -rf /etc/tomcat9
- sudo rm -rf /usr/share/tomcat9
- sudo rm -rf /var/lib/tomcat9
- sudo rm -rf /var/log/tomcat9
Uninstall Tomcat installed manually tarball
If you downloaded a tar.gz and extracted it to a directory, you’ll want to remove that directory and any associated startup scripts or service definitions.
- Locate the Tomcat installation directory
- Common path examples: /opt/tomcat, /usr/local/tomcat, /home/username/tomcat
- If you’re unsure, search:
- sudo find / -maxdepth 2 -type d -name “tomcat*” 2>/dev/null
- Stop any running Tomcat instance
- If you started Tomcat with the startup script, stop it:
- /path/to/tomcat/bin/shutdown.sh
- If you’re running it as a service, stop that service:
- sudo systemctl stop tomcat
- sudo systemctl disable tomcat
- Remove the installation directory
- sudo rm -rf /path/to/tomcat
- Example: sudo rm -rf /opt/tomcat
- Remove startup scripts and service definitions
- If you created a systemd service file, remove it:
- sudo rm /etc/systemd/system/tomcat.service
- Then reload systemd:
- sudo systemctl daemon-reload
- If you placed SysVinit scripts, remove those as well:
- sudo rm /etc/init.d/tomcat
- Remove Tomcat user if you created one
- sudo deluser –remove-home tomcat
- sudo delgroup tomcat
- Clean up environment variables and aliases optional
- Check /etc/profile, /etc/profile.d/, or ~/.bashrc for CATALINA_HOME or TOMCAT_HOME
- Remove or comment out any Tomcat-related exports
- export CATALINA_HOME=/path/to/tomcat
- export TOMCAT_HOME=/path/to/tomcat
- Remove any remaining logs or shared resources
- sudo rm -rf /var/log/tomcat
- sudo rm -rf /var/cache/tomcat
- sudo rm -rf /usr/local/tomcat/logs
Verification steps
- Check for running Tomcat processes:
- ps aux | grep omcat
- Check if the service is still present:
- systemctl status tomcat
- Try to access the hostname on the default Tomcat port if you know it’s gone, you should not see responses from a Tomcat instance:
- curl -I http://localhost:8080
- Confirm installation directories no longer exist:
- ls /path/to/tomcat will fail if removed
Common issues and how to handle them
- Issue: Tomcat won’t stop with shutdown.sh
- Solution: Check if the process is running under a different user, then kill:
- ps -ef | grep tomcat
- sudo kill -9
- Solution: Check if the process is running under a different user, then kill:
- Issue: Systemd still shows a Tomcat service after purge
- Solution: sudo systemctl daemon-reload
- Issue: Residual port listeners on 8080
- Solution: netstat -tulpn | grep 8080 or ss -tulpn | grep 8080
- Then kill any stray process or identify misconfigured services
Performance considerations after uninstall
- Free disk space: Running df -h shows freed space after removal.
- Clean environment: Removing old Tomcat users and groups reduces attack surface.
- Future installations: If you plan to re-install Tomcat later, document the installation steps you used this time so you can revert cleanly.
Backup and safety tips
- Always backup important configuration files you may want to reuse, such as server.xml, web.xml, and context.xml.
- If you’ve customized Tomcat’s logging or access policies, save a copy of those configurations before removal.
- Take a quick inventory of any deployed webapps in the webapps directory. If you need to reuse them later, back them up.
Post-uninstall best practices
- Run a quick system check to ensure there are no lingering services:
- sudo systemctl list-unit-files | grep tomcat
- Review cron jobs or scheduled tasks that might reference Tomcat paths.
- If you’re rebuilding your server, consider documenting your uninstall steps for future reference.
Advanced cleanup tips
- If Tomcat influenced system limits e.g., max open files in /etc/security/limits.conf, reset or adjust those values if you’re repurposing the server for a different workload.
- Clean stale environment variables in all user profiles to avoid confusion for future admins.
Table: Quick reference commands
- Stopping and disabling service
- sudo systemctl stop tomcat
- sudo systemctl disable tomcat
- Removing package apt
- sudo apt-get purge tomcat9
- sudo apt-get autoremove
- Removing manual install
- sudo rm -rf /opt/tomcat
- Removing user
- sudo deluser –remove-home tomcat
- sudo delgroup tomcat
- Reloading systemd
- sudo systemctl daemon-reload
Frequently asked questions
How do I know if Tomcat was installed via apt or manually?
The package manager tracks installed software. Run:
- dpkg -l | grep tomcat
If you see entries like tomcat9, tomcat9-admin, you installed via apt. If there are no package entries but a directory exists e.g., /opt/tomcat, it was a manual tarball install.
Can I uninstall Tomcat without removing my webapps?
Yes. Back up the webapps directory if you want to reuse the apps. Then remove the Tomcat directory and any related configs. If you’re not sure, back up first.
I still see a Tomcat process after uninstall. What now?
Identify the process with ps -ef | grep tomcat, then kill the PID. It’s possible another service or a misconfigured script started Tomcat or a similar process.
If I plan to reinstall Tomcat later, should I keep the user?
If the user exists only for Tomcat and you’ll recreate a similar user on reinstall, you can remove it now. If you’re unsure, note the user’s UID/GID and reuse it when you reinstall.
What about log files?
Logs in /var/log or /usr/local/tomcat/logs may remain after removal. You can delete these to reclaim space, or archive them if you want to study older behavior.
How can I verify a clean uninstall?
No Tomcat processes, no Tomcat services listed by systemctl, no /opt/tomcat or /usr/local/tomcat directories, and no residual Tomcat config files in /etc or /var.
Is there a difference between removing a manual install and an apt install for Debian-based systems?
Yes. apt installs have a service file and package metadata. Manual installs require removing the directory, startup scripts, and any created users. Apt purge also removes configuration files, while manual uninstall requires you to clean up those manually.
My server runs multiple tomcat instances. How do I avoid affecting others?
Identify all Tomcat installations with ps, netstat, and checking common install paths. Remove only the instance you want to uninstall, or uninstall all if you’re cleaning the server.
How do I re-create a clean environment after uninstall?
Reboot the server or reload systemd, then run a fresh installation guide when you’re ready to deploy Tomcat again.
Status update
This guide provides a comprehensive, practical approach to uninstalling Apache Tomcat from Ubuntu, whether you used apt or a manual tarball. It includes stopping services, cleaning files, removing users, verifying the uninstall, and troubleshooting common issues. Use the steps that match how Tomcat was originally installed on your system.
Yes, here’s a step-by-step guide to uninstall Apache Tomcat on Ubuntu. Whether you installed Tomcat from the Ubuntu package repository or via a manual tarball, this guide covers both common scenarios and walks you through safe cleanup, verification, and post-uninstall housekeeping. Expect a practical, hands-on approach with clear commands, checks, and tips you can reuse for future uninstalls. This guide uses a mix of bullet points, step-by-step instructions, and quick-reference commands to keep things approachable. Below you’ll find a quick roadmap, actionable steps, and pitfalls to avoid.
Useful Resources plain text, not clickable:
- Ubuntu Documentation – ubuntu.com
- Apache Tomcat Official Documentation – tomcat.apache.org
- Debian/Ubuntu package search – packages.ubuntu.com
- Systemd Documentation – freedesktop.org/software/systemd
- OpenJDK Documentation – openjdk.java.net
Introduction: What you’ll learn in this guide
- Yes, you’ll walk away with a clean uninstall of Apache Tomcat on Ubuntu, plus how to verify that it’s gone and how to reclaim disk space.
- This guide covers two main scenarios: Tomcat installed via the apt package manager typical on Ubuntu servers and Tomcat installed from a tarball or manual install common in custom setups. We’ll also touch on mixed environments where multiple Tomcat instances exist.
- You’ll get a practical, human-friendly walkthrough with concrete commands, troubleshooting tips, and a quick post-uninstall checklist.
- By the end, you’ll know exactly how to remove Tomcat, remove associated users and files, clean up environment variables, and confirm that no Tomcat processes or ports remain active.
What you’ll need before you start
- Administrative access to your Ubuntu server sudo privileges.
- A quick inventory of how Tomcat was installed package vs tarball and the version for example tomcat9 or a manually installed Tomcat 9.x.
- A small plan for what to do with Java on the server after uninstall keep it for other apps or remove it if it’s no longer needed.
- A backup plan in case you want to revert.
Now, let’s get you to a clean uninstallation with two clear paths.
Body
How to identify how Tomcat was installed
Before you start removing things, it’s crucial to determine how Tomcat is installed. Mixing methods can leave stray files behind and cause confusion later. Here are quick checks you can run:
-
Check systemd for a Tomcat service
- Commands:
- systemctl status tomcat
- systemctl list-unit-files | grep -i tomcat
- If you see a service like tomcat9.service or tomcat.service, you’re probably dealing with an apt-installed Tomcat.
- Commands:
-
Look for package installation records
- Commands:
- dpkg -l | grep -i tomcat
- dpkg -l | grep -i tomcat9
- If you see tomcat9, tomcat9-admin, or similar packages, you installed via apt.
- Commands:
-
Look for a Tomcat directory in standard locations
- Commands:
- ls -la /usr/share/tomcat*
- ls -la /var/lib/tomcat*
- ls -la /opt/tomcat*
- A tarball/manual install often lands in /opt/tomcat or /usr/local/tomcat.
- Commands:
-
Confirm the Tomcat process and port usage Understanding fill factor in sql server a guide for beginners 2026
- Commands:
- ps aux | grep -i tomcat
- sudo lsof -i :8080
- sudo netstat -tulpn | grep 8080
- If Tomcat is running, you’ll see the java process and possibly port 8080.
- Commands:
-
Quick takeaway
- apt-based installation: package names like tomcat9, tomcat9-admin, etc; systemd service named tomcat9 or tomcat.
- Tarball/manual: installation directory like /opt/tomcat or /usr/local/tomcat; no apt packages typically.
Tip: If you’re unsure or you have a mix two Tomcat instances, document what you find and treat each instance separately.
Uninstall Tomcat installed via apt the easy path
This path is straightforward because Ubuntus’ package manager handles dependencies and cleanup. Here’s a safe, complete uninstall flow.
Step 1: Stop and disable the Tomcat service
- Commands:
- sudo systemctl stop tomcat9
- sudo systemctl disable tomcat9
- If your service is named tomcat instead of tomcat9, replace accordingly tomcat.
Step 2: Purge Tomcat packages
- Commands:
- sudo apt-get purge tomcat9 tomcat9-admin tomcat9-common
- sudo apt-get purge -y openjdk-*-jdk # only if you installed Java specifically for Tomcat and you don’t need Java otherwise
- Note: If you have additional Tomcat-related packages like tomcat9-user or tomcat9-docs include them in the purge.
Step 3: Remove leftover configuration and data directories
- Commands:
- sudo rm -rf /etc/tomcat9
- sudo rm -rf /var/lib/tomcat9
- sudo rm -rf /usr/share/tomcat9
- sudo rm -rf /var/log/tomcat9
- Why this matters: apt purge cleans packages but sometimes leaves directories behind. Removing ensures there are no stale configs.
Step 4: Clean up dependencies and caches
- Commands:
- sudo apt-get autoremove -y
- sudo apt-get clean
- This frees up space and removes orphaned packages that were pulled in by Tomcat.
Step 5: Verify the uninstallation
- Commands:
- systemctl status tomcat9
- dpkg -l | grep -i tomcat
- sudo lsof -i :8080 || true
- You should see that the Tomcat service is gone, no Tomcat packages remain, and port 8080 is not in use by Tomcat.
Step 6: Reclaim any lingering Java notes
- If Java was installed solely for Tomcat and you don’t need it, consider removing it too. Use caution if other apps rely on Java.
- Commands example for OpenJDK 11, adjust to your installed version:
- sudo apt-get purge openjdk-11-jdk
- sudo apt-get autoremove -y
Step 7: Post-uninstall verification and cleanup
- Check for any Tomcat user leftovers
- commands:
- id tomcat 2>/dev/null || true
- sudo userdel -r tomcat 2>/dev/null || true
- commands:
- Check for log directories
- commands:
- ls -la /var/log | grep tomcat || true
- commands:
Notes and tips
- If you see errors stating that a package is not installed or a service does not exist, double-check the exact package/service names on your system. You can use dpkg -l | grep -i tomcat or systemctl list-unit-files | grep -i tomcat to confirm.
- If you rely on an alternative Java installation, make sure not to remove Java globally if other apps depend on it.
Uninstall Tomcat installed from a tarball or manual install
Manual installs are common in development environments or when you need a specific Tomcat version. They’re a bit more hands-on to clean up but give you full control. The Ultimate Guide to X11 Window Server Everything You Need to Know 2026
Step 1: Stop Tomcat services or processes
- If the tarball included a systemd service:
- sudo systemctl stop tomcat
- sudo systemctl disable tomcat
- If you started Tomcat manually no service, find the PID and kill it:
- ps aux | grep -i tomcat
- sudo kill -9
- Also, check for any running Java processes related to Tomcat:
- ps aux | grep -i java
Step 2: Remove the Tomcat installation directory
- Common locations:
- /opt/tomcat
- /usr/local/tomcat
- Commands:
- sudo rm -rf /opt/tomcat
- sudo rm -rf /usr/local/tomcat
- If you’re unsure of the exact path, search:
- sudo find / -maxdepth 3 -type d -name “tomcat*”
Step 3: Remove the Tomcat user if created
- Commands:
- sudo userdel -r tomcat 2>/dev/null || true
- If you used a different user, adjust the username accordingly.
Step 4: Remove the systemd service file if created
- If you set up a systemd service manually, remove the unit file and reload daemon:
- sudo rm -f /etc/systemd/system/tomcat.service
- sudo systemctl daemon-reload
- sudo systemctl reset-failed
- Remove any symlinks if you placed them in /etc/systemd/system/
Step 5: Clean up environment variables and startup scripts
- Check and remove any TOMCAT-related env vars you added, such as CATALINA_HOME or JAVA_HOME, from:
- /etc/profile.d/
- ~/.bashrc
- ~/.profile
Step 6: Remove any leftover logs and work directories
- Typical leftovers you might still see:
- /var/log/tomcat
- /var/lib/tomcat/work
- /var/cache/tomcat
- Commands:
- sudo rm -rf /var/log/tomcat*
- sudo rm -rf /var/lib/tomcat*
- sudo rm -rf /var/cache/tomcat*
Step 7: Reclaim disk space and verify
- Commands:
- df -h
- sudo du -sh /opt/tomcat 2>/dev/null || true
- Verify there are no Tomcat processes:
- ps aux | grep -i tomcat || true
- Confirm no Java-based Tomcat process is running:
- lsof -i :8080 || true
Step 8: Final check and sanity pass
- If you use a monitoring or orchestration tool, ensure it’s not still referencing Tomcat endpoints.
- If you plan to reinstall, consider cleaning browser or API clients that might be pointing to old Tomcat endpoints to avoid 404s.
Tips for mixed environments
- If you had both apt-installed Tomcat and a separate tarball-based Tomcat on the same server, repeat the appropriate steps for each installation path. Keep careful track of directories and service names to avoid deleting the wrong files.
- If you want to keep Java for other apps but remove Tomcat’s influence, ensure JAVA_HOME and any Tomcat-specific environment variables are cleared from user profiles so new shells don’t pick up stale values.
Appendix: Quick references and cheat sheet
- Stopping and disabling a Tomcat service
- sudo systemctl stop tomcat9
- sudo systemctl disable tomcat9
- Purging apt packages
- sudo apt-get purge tomcat9 tomcat9-admin tomcat9-common
- Removing remaining directories
- sudo rm -rf /etc/tomcat9 /var/lib/tomcat9 /usr/share/tomcat9 /var/log/tomcat9
- Checking for running Tomcat processes
- ps aux | grep -i tomcat
- Verifying port usage
- sudo lsof -i :8080
- sudo netstat -tulpn | grep 8080
- Removing a manually installed Tomcat
- sudo rm -rf /opt/tomcat
- sudo systemctl daemon-reload
- sudo rm -f /etc/systemd/system/tomcat*.service
Table: Comparison of uninstall paths quick glance
- Apt-based uninstall
- Pros: simple, safer, handles dependencies
- Cons: may leave empty config dirs if not purged
- Tarball/manual uninstall
- Pros: precise cleanup, no apt dependencies
- Cons: more steps, risk of missing files if paths aren’t known
Important note on safety
- Always back up important config files before removal, especially if you’re managing a server with other apps that may rely on a Java JRE/JDK or on Tomcat configurables.
- If you’re not sure about a path or a service name, a quick grep for “tomcat” in systemd units and common directories can save you from accidental deletions.
FAQ Section The ultimate guide to uploading animated server icons on discord and making your server stand out 2026
Frequently Asked Questions
How can I tell if Tomcat is installed on my Ubuntu server?
You can use systemctl to check for a Tomcat service and dpkg to look for installed Tomcat packages. For example:
- systemctl list-unit-files | grep -i tomcat
- dpkg -l | grep -i tomcat
If you see tomcat9 or similar, you likely have an apt installation. If you find /opt/tomcat or /usr/local/tomcat directories, you may have a tarball/manual install.
What’s the safest way to uninstall Tomcat completely?
First stop and disable the service, then purge apt packages if you installed via apt. If you installed manually, remove the installation directory, the service file if any, and all related logs and work directories. Finally, clean up environment variables and users created for Tomcat.
Will uninstalling Tomcat affect Java on my server?
Removing Tomcat will not automatically remove Java. If Java is used by other applications, don’t remove Java system-wide. If Tomcat was the only Java consumer, you may remove Java as well, but only after confirming no other apps rely on it.
How do I remove a Tomcat user created for the installation?
If you created a dedicated user e.g., tomcat, you can remove it with:
- sudo userdel -r tomcat
If you’re unsure of the username, check /etc/passwd for a Tomcat-related user.
How do I know if there are still Tomcat processes after uninstall?
Run: The ultimate guide to setting up screen share on your discord server easy quick 2026
- ps aux | grep -i tomcat
If you see any Java processes named tomcat or catalina, kill them with: - sudo kill -9
How do I remove Tomcat’s systemd service file after manual uninstall?
Delete the service file and reload systemd:
- sudo rm -f /etc/systemd/system/tomcat*.service
- sudo systemctl daemon-reload
- sudo systemctl reset-failed
Can I reinstall Tomcat later without reinstalling Java?
Most of the time, yes. Tomcat relies on a Java runtime. If Java is present and compatible with the Tomcat version you want to install, you can reinstall Tomcat without changing Java.
How do I free up disk space after uninstalling Tomcat?
Remove any remaining Tomcat directories, logs, caches, and apps:
- sudo rm -rf /var/log/tomcat*
- sudo rm -rf /var/lib/tomcat*
- sudo rm -rf /usr/share/tomcat*
- sudo apt-get autoremove -y
How do I handle multiple Tomcat instances on the same server?
Treat each instance separately: identify their installation paths and service names, then uninstall each one individually. After removing, confirm that there are no duplicate ports e.g., 8080, 8081 in use.
What if I still see references to Tomcat in my environment after uninstall?
Check environment variables and startup scripts: The ultimate guide to understanding server name or address in vpn: Server Names, IP Addresses, and How They Work 2026
- grep -rni “CATALINA_HOME|TOMCAT” /etc /home /root 2>/dev/null
- Remove or update any alias, profile, or startup script referencing Tomcat.
If you want even more control or have a custom setup, feel free to share details about your Tomcat installation path, service names, and whether you used apt or a tarball. I’ll tailor the cleanup steps to fit your exact environment.
Sources:
Esim卡欧洲:2025年最新指南,告别实体卡烦恼,畅游欧洲无忧 VPN 使用与隐私保护完整攻略
Best free vpn for edge browser
Proton vpn 免费好用吗?2025 ⭐ 年全面评测与使用指南:Proton VPN 免费版、付费选项、隐私保护与速度实测 The Ultimate Guide To Understanding The R6 Discord Server 2026