Tomcat Version Command Line: How to Check from Terminal
I was setting up a CI/CD pipeline for a Java web application and needed to verify the Tomcat version on a remote server. The problem? The server was headless, and I only had SSH access. I couldn’t just open a browser and check the Tomcat Manager GUI.
After some digging, I found two simple command-line methods that work perfectly for this scenario.
The Problem
When you’re working on headless servers, automated deployment scripts, or SSH sessions, you don’t have access to GUI tools. You need a way to check the Tomcat version without starting the server or using a web interface.
I tried a few approaches before finding the right solution.
Finding the Right Commands
First, I navigated to my Tomcat installation directory:
cd /opt/tomcatThen I discovered two scripts in the bin directory that display version information.
Method 1: Using version.sh
The most straightforward approach is using the dedicated version script:
./bin/version.shOutput:
Using CATALINA_BASE: /opt/tomcatUsing CATALINA_HOME: /opt/tomcatUsing CATALINA_TMPDIR: /opt/tomcat/tempUsing JRE_HOME: /usrUsing CLASSPATH: /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jarServer version: Apache Tomcat/10.1.52Server built: Jan 23 2026 19:29:07 UTCServer number: 10.1.52.0OS Name: LinuxOS Version: 6.1.0-30-amd64Architecture: amd64JVM Version: 17.0.18+8-Debian-1deb12u1JVM Vendor: DebianThis script shows everything: the Tomcat version, build date, OS details, and JVM information.
Method 2: Using catalina.sh version
The main catalina script also supports a version argument:
./bin/catalina.sh versionThis produces identical output to version.sh. I found this useful when I was already working with catalina.sh for other server operations.
Why These Scripts Work So Well
The key insight is that these scripts don’t require Tomcat to be running. They read version information directly from the Tomcat JAR files and system properties. This makes them perfect for:
- Remote servers via SSH - No need to start the server
- CI/CD pipelines - Script-friendly output
- Automation scripts - Easy to parse and log
Practical Examples
Extract Just the Version Number
When I needed just the version for my deployment script, I filtered the output:
./bin/version.sh | grep "Server version"Output:
Server version: Apache Tomcat/10.1.52Using catalina.jar Directly
I also discovered an alternative method that works without the shell scripts:
java -cp /opt/tomcat/lib/catalina.jar org.apache.catalina.util.ServerInfoOutput:
Server version: Apache Tomcat/10.1.52Server built: Jan 23 2026 19:29:07 UTCServer number: 10.1.52.0OS Name: LinuxOS Version: 6.1.0-30-amd64Architecture: amd64JVM Version: 17.0.18+8-Debian-1deb12u1JVM Vendor: DebianThis approach is useful when the shell scripts aren’t available or when you want to check Tomcat from a different working directory.
Common Mistakes I Made
Mistake 1: Wrong Directory
I initially tried running the scripts from my home directory:
$ ~/version.shbash: /home/user/version.sh: No such file or directoryThe scripts must be run relative to the Tomcat installation directory or with full paths.
Mistake 2: Missing Execute Permissions
On one server, I got a permission error:
$ ./bin/version.shbash: ./bin/version.sh: Permission deniedFixed with:
chmod +x bin/version.sh bin/catalina.shMistake 3: Confusing with Other Scripts
I initially tried ./bin/startup.sh thinking it would show version info, but that only starts the server. The version scripts are specifically for displaying version information.
Windows Users
If you’re on Windows, use the batch files instead:
C:\tomcat\bin\version.batC:\tomcat\bin\catalina.bat versionThese produce the same output format as the Unix/Linux scripts.
Integration into Automation
Here’s how I integrated version checking into my deployment script:
#!/bin/bash
TOMCAT_HOME="/opt/tomcat"REQUIRED_VERSION="10.1"
# Check Tomcat versionCURRENT_VERSION=$($TOMCAT_HOME/bin/version.sh | grep "Server version" | awk '{print $4}')
if [[ ! $CURRENT_VERSION == $REQUIRED_VERSION* ]]; then echo "ERROR: Tomcat version mismatch. Required: $REQUIRED_VERSION.x, Found: $CURRENT_VERSION" exit 1fi
echo "Tomcat version check passed: $CURRENT_VERSION"# Continue with deployment...This script extracts the version number and validates it before proceeding with deployment.
When to Use Each Method
Use version.sh when:
- You just need to check the version
- You’re in the Tomcat directory
- You want the simplest command
Use catalina.sh version when:
- You’re already using catalina.sh for other operations
- You want consistency with other catalina commands
Use the catalina.jar method when:
- Shell scripts aren’t available
- You need to run from outside the Tomcat directory
- You’re in a constrained environment
Final Words + More Resources
My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me
Here are also the most important links from this article along with some further resources that will help you in this scope:
Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!
Comments