Checking your Tomcat version in Linux helps you plan for updates and ensure application compatibility. If you’re managing a Java web server, knowing how to check tomcat version in linux is a basic but essential skill. This guide walks you through multiple methods, from simple commands to inspecting configuration files.
Whether you’re a system administrator or a developer, you’ll find a method that fits your setup. Let’s start with the quickest ways to get the version number.
Why Check Your Tomcat Version
Knowing your Tomcat version helps you identify security patches and plan upgrades. It also ensures your Java applications run on a supported server. Outdated versions can have vulnerabilities that put your system at risk.
Regular version checks are part of good server maintenance. They help you avoid compatibility issues with newer Java releases or web frameworks.
How To Check Tomcat Version In Linux
There are several reliable methods to find your Tomcat version. The best approach depends on how Tomcat was installed and whether it’s currently running. Below are the most common techniques.
Method 1: Using The Version Script
Tomcat includes a version.sh script in its bin directory. This is the most direct method if you have access to the Tomcat installation folder.
- Navigate to the Tomcat bin directory. The path is usually
/opt/tomcat/binor/usr/share/tomcat/bin. - Run the script with the command:
./version.sh - Look for the output line that says “Server version: Apache Tomcat/X.Y.Z”
If you get a permission denied error, make the script executable first: chmod +x version.sh. Then run it again.
This script works even if Tomcat is not running. It reads the version from the server library files.
Method 2: Checking The Catalina JAR File
Another reliable method is to inspect the catalina.jar file. This JAR contains version information in its manifest.
- Go to the Tomcat
libdirectory:cd /path/to/tomcat/lib - Run:
unzip -p catalina.jar META-INF/MANIFEST.MF | grep "Implementation-Version" - The output will show something like:
Implementation-Version: 9.0.73
This method works without starting Tomcat. It’s useful when the server is down or you’re auditing an offline installation.
Method 3: Using The Startup Script
If Tomcat is installed but not running, you can check the startup script for version hints. Some installations embed the version in the script comments.
Run: head -20 /path/to/tomcat/bin/startup.sh. Look for lines like # Apache Tomcat/9.0.73. This isn’t always present, but it’s worth a quick look.
Method 4: Checking The Manager App
If Tomcat is running and you have web access, the Manager app shows the version. This method requires the Manager app to be deployed and accessible.
- Open a browser and go to:
http://your-server:8080/manager/html - Log in with your Tomcat admin credentials.
- The version appears at the top of the page, usually as “Apache Tomcat/X.Y.Z”
You can also check via command line using curl: curl -u admin:password http://localhost:8080/manager/text/list. The response includes the Tomcat version.
Method 5: Checking The Server Info Page
The default Tomcat homepage often shows the version. Access http://your-server:8080 and look at the footer or the “Server Info” section. This works if the default ROOT app is deployed.
If you see a 404, the default page may have been removed. In that case, try the Manager app method instead.
Method 6: Using RPM Or APT Package Managers
If Tomcat was installed via a package manager, you can query the package version. This works for system-wide installations.
For RPM-based systems (CentOS, RHEL, Fedora):
- Run:
rpm -qa | grep tomcat - Or:
yum list installed | grep tomcat - The output includes the version number in the package name.
For Debian-based systems (Ubuntu, Debian):
- Run:
dpkg -l | grep tomcat - Or:
apt list --installed | grep tomcat - Look for the version field in the output.
This method is fast and doesn’t require navigating to the Tomcat directory.
Method 7: Checking The Log Files
Tomcat logs its version during startup. If the server has been started recently, check the catalina.out log file.
Run: grep "Server version" /path/to/tomcat/logs/catalina.out. This shows the version line from the last startup.
If the log is rotated, check older logs: grep "Server version" /path/to/tomcat/logs/catalina.*.log.
Method 8: Checking The Release Notes File
Tomcat installations include a RELEASE-NOTES file in the root directory. This file contains the version number at the top.
Run: head -10 /path/to/tomcat/RELEASE-NOTES. The first line usually says “Apache Tomcat Version X.Y.Z”.
This is a static file that doesn’t require Tomcat to be running.
Method 9: Using Java To Check The Version
If you have the Tomcat libraries on your classpath, you can write a small Java program to check the version. This is more advanced but works in scripted environments.
Create a file CheckVersion.java with:
import org.apache.catalina.util.ServerInfo;
public class CheckVersion {
public static void main(String[] args) {
System.out.println(ServerInfo.getServerInfo());
}
}
Compile and run with the Tomcat libraries: javac -cp /path/to/tomcat/lib/* CheckVersion.java && java -cp .:/path/to/tomcat/lib/* CheckVersion.
This prints the full server info string including the version.
Method 10: Checking The Environment Variables
Some installations set the CATALINA_HOME or TOMCAT_HOME environment variable. You can use this to find the version.
Run: echo $CATALINA_HOME. Then navigate to that directory and use one of the methods above.
If the variable is set, you can combine commands: $CATALINA_HOME/bin/version.sh.
Common Issues And Troubleshooting
Sometimes the version check doesn’t work as expected. Here are common problems and fixes.
Permission Denied Errors
If you get “Permission denied” when running version.sh, the script isn’t executable. Fix it with: chmod +x /path/to/tomcat/bin/version.sh. Then try again.
Tomcat Not Found In Expected Location
If the standard paths don’t work, find Tomcat using: find / -name "catalina.jar" 2>/dev/null. This searches the entire filesystem for the Tomcat library.
Multiple Tomcat Installations
If you have multiple Tomcat instances, each has its own version. Check each installation separately using the methods above. Pay attention to which CATALINA_HOME each instance uses.
Version Script Shows Wrong Version
If the version script shows an unexpected version, the catalina.jar might be corrupted or from a different installation. Verify by checking the RELEASE-NOTES file or the package manager.
Automating Version Checks
For regular monitoring, you can automate version checks. Here’s a simple script that checks the version and logs it.
#!/bin/bash
TOMCAT_HOME="/opt/tomcat"
VERSION=$($TOMCAT_HOME/bin/version.sh 2>/dev/null | grep "Server version" | awk '{print $3}')
echo "$(date): Tomcat version is $VERSION" >> /var/log/tomcat-version.log
Run this script via cron to keep a history of version changes. This helps track upgrades and detect unauthorized modifications.
Understanding Tomcat Version Numbers
Tomcat versions follow a three-part format: X.Y.Z. The major version (X) indicates significant changes. Minor version (Y) adds features. Patch version (Z) includes bug fixes and security patches.
For example, version 9.0.73 means major version 9, minor version 0, and patch 73. Always run the latest patch version for your major release to stay secure.
Tomcat 10 introduced major changes like the Jakarta namespace. If you see version 10.x, your applications may need updates to work correctly.
Checking Version For Docker Containers
If Tomcat runs in a Docker container, you can check the version from the host or inside the container.
From the host: docker exec <container_name> /usr/local/tomcat/bin/version.sh
Inside the container: Use the same methods as a regular Linux installation. The default path in official Tomcat images is /usr/local/tomcat.
You can also check the image version: docker inspect <container_name> | grep "Image". This shows the base image, which may include the Tomcat version in the tag.
Checking Version For Systemd Services
If Tomcat runs as a systemd service, you can check the version using the service status.
Run: systemctl status tomcat. The output may include the version in the description line. If not, use the version.sh method with the service’s working directory.
Find the service file: systemctl cat tomcat. Look for the WorkingDirectory or ExecStart line to locate the Tomcat installation path.
Security Considerations
Exposing the Tomcat version in web pages can help attackers target known vulnerabilities. Consider hiding the version from the default server info page.
To hide the version, edit the server.xml file and set the server attribute on the Connector element to a custom value. This doesn’t change the actual version but prevents it from being displayed.
For internal checks, use the command-line methods instead of relying on web pages. This reduces the risk of information leakage.
Frequently Asked Questions
How do I check Tomcat version if it’s not installed in the default location?
Use the find command to locate catalina.jar: find / -name "catalina.jar" 2>/dev/null. Then navigate to that directory and use the version.sh script or the JAR inspection method.
Can I check the Tomcat version without stopping the server?
Yes, most methods work on a running server. The version.sh script, JAR inspection, and package manager queries don’t require stopping Tomcat. The Manager app and server info page also work while the server is running.
What if the version.sh script is missing?
If version.sh is missing, use the JAR inspection method: unzip -p /path/to/tomcat/lib/catalina.jar META-INF/MANIFEST.MF | grep "Implementation-Version". Alternatively, check the RELEASE-NOTES file or use the package manager.
How do I check the Tomcat version for a specific web application?
The web application itself doesn’t have a version separate from the Tomcat server. However, you can check the application’s META-INF/MANIFEST.MF file inside its WAR file for its own version. The Tomcat version is server-wide.
Why does the version shown by the Manager app differ from the version.sh output?
This can happen if multiple Tomcat instances are running or if the Manager app is from a different installation. Ensure you’re checking the correct instance. The version.sh script reads from the local catalina.jar, which is more reliable.
Conclusion
Knowing how to check tomcat version in linux is a straightforward task with multiple approaches. You can use the version.sh script, inspect the catalina.jar file, query the package manager, or check the web interface. Each method works in different scenarios, so pick the one that fits your setup.
Regular version checks help you maintain a secure and compatible Tomcat environment. Combine this with automated monitoring to stay on top of updates. If you run into issues, the troubleshooting tips above should help you resolve them quickly.
Now you have a complete toolkit for checking your Tomcat version on Linux. Use these methods to keep your server up to date and your applications running smoothly.