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 Efficiently creating partition indexes in sql server 2012 a step by step guide
- 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. Configure load balancer in windows server 2012 r2 step by step guide
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 How to Add Dank Memer to Your Discord Server a Step by Step Guide
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?
- 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: How to Hide Your DNS Server The Ultimate Guide To DNS Privacy, DoH, DoT, And VPNs
- 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 免费版、付费选项、隐私保护与速度实测 How to generate a database diagram in sql server 2016 step by step guide