WildFly cheatsheet for Linux Administrators
This is my JBoss / WildFly cheatsheet I use for managing the application server on a Linux box. Enjoy it and welcome any contribution to the cheatsheet.
WildFly / JBoss CLI
How to execute commands in non-interactive way:
jboss-cli.sh --connect --command=":reload"
How to connect to a non default host/port
jboss-cli.sh --connect --controller=192.168.0.1:9990
How to execute script in a file
jboss-cli.sh --file=test.cli
How to run in GUI mode:
jboss-cli.sh --gui
How to run in Admin-only mode:
jboss-cli.sh --admin-only
How to shutdown and restart the server:
shutdown --restart=true
How to start the server in embedded mode:
embed-server --server-config=server-config.xml --std-out=echo
How to stop the embedded server:
[standalone@embedded /] stop-embedded-server
How to suspend a server with a timeout:
:suspend(timeout=60)
Resume a server:
:resume
WildFly Domain
Start all servers in a Host:
/host=master:start
Stop all servers in a Host:
/host=master:stop
Suspend all servers in a Domain:
:suspend-servers(timeout=60)
Suspend a single server in a managed domain.
/host=master/server-config=server-one:suspend(timeout=60)
Suspend all servers in a server group.
/server-group=main-server-group:suspend-servers(timeout=60)
JVM
Standalone mode
Set in standalone.conf:
JAVA_OPTS="-Xms64m -Xmx512m -XX:MaxMetaspaceSize=256m"
Domain mode
Set the default heap settings for a domain Host. Note that PermGen is long gone — on any JDK 8+ (WildFly has required JDK 11+ for several major versions now, with JDK 17 or 21 recommended for current releases) you tune Metaspace instead:
/host=HOST/jvm=production_jvm:add
(
heap-size=2048m,
max-heap-size=2048m,
max-metaspace-size=512m,
stack-size=1024k,
jvm-options=["-XX:-UseParallelGC"]
)
Set the default heap settings for a domain host:
/host=HOST/jvm=default:write-attribute(name=heap-size,value="1024m")
Set the heap size for a server group:
/server-group=groupName/jvm=default:write-attribute(name=heap-size,value="1024m")
Set the heap size for a single server:
/host=HOST/server-config=server-one/jvm=default:write-attribute(name=heap-size,value="1024m")
Set a server to use the default JVM settings for the domain.
/host=HOST/server-config=server-one/jvm=production_jvm:add()
Running in a container? Modern JDKs are container-aware by default (-XX:+UseContainerSupport is on since JDK 10+), so hard-coding -Xmx against the host’s RAM is usually the wrong move. Prefer a percentage of the container’s memory limit, so the same image behaves correctly regardless of which pod size it lands on:
JAVA_OPTS="-XX:MaxRAMPercentage=75.0 -XX:MinRAMPercentage=50.0"
Deploy
Deploy an application to a standalone server.
deploy /path/to/app/myapp.war
Deploy an application to a Server Group:.
deploy --server-groups=main-server-group /path/to/app/app.war
Batch
[standalone@localhost:9990 /] batch
[standalone@localhost:9990 / #] /subsystem=datasources/data-source="java\:\/H2DS":enable
[standalone@localhost:9990 / #] /subsystem=messaging-activemq/server=default/jms-queue=newQueue:add
You can execute a batch using the run-batch command:
[standalone@localhost:9990 / #] run-batch
Variables
How to set a variable in CLI:
set s1=/host=master/server=server-one
$s1/subsystem=datasources/data-source=ExampleDS:test-connection-in-pool
Alias
How to create an alias in CLI:
alias create='/subsystem=ejb3/strict-max-bean-instance-pool=demo:add(max-pool-size=10)'
JMS
Add JMS queue (the underlying broker is ActiveMQ Artemis since the messaging-activemq subsystem replaced legacy HornetQ, but the CLI shortcut commands below are unchanged):
jms-queue add --queue-address= jms.queue.ExampleQueue --entries=java:/jms/queue/exampleQueue,java:/jboss/exported/jms/queue/exampleQueue
Add JMS Topic:
jms-topic add --topic-address=jms.topic.ExampleTopic --entries=java:/jms/topic/exampleTopic,java:/jboss/exported/jms/topic/exampleTopic
Transactions
How to check a transaction attribute:
/subsystem=transactions/log-store=log-store/transactions=0\:defe7f000002\:-c71efc2\:4f9e6f8f\:9:read-resource
How to view all prepared transactions:
/subsystem=transactions/log-store=log-store:read-children-names(child-type=transactions)
How to delete a transaction:
/subsystem=transactions/log-store=log-store/transactions=0\:defe7f000002\:-b66efc2\:c71efc2\:9:delete
How to recover a transaction:
/subsystem=transactions/log-store=log-store/transactions=0\:defe7f000002\:-b66efc2\:c71efc2\:9/participants=2:recover
Mixed Bash commands useful for WildFly admins
How to store in a bash variable the result of a Command Line readAttribute
heapused=$(./jboss-cli.sh -c "/core-service=platform-mbean/type=memory:read-attribute(name=heap-memory-usage)" | grep "used" | awk '{print $3}' | sed 's/L,//')
How to find HTTP requests (from access log file) that took more than 100 seconds:
egrep -R "TimeTaken: 1[0-9]{2}.[0-9]" access.log*
How to check that the application web.war is deployed
APPS=$(./jboss-cli.sh --controller=127.0.0.1:9999 -c "deploy")
list=( $APPS )
deployed=false
for i in "${list[@]}"
do
#echo $i
if [ $i = "web.war" ] ; then
deployed=true;
fi
done
if [ "$deployed" = true ]
then
echo "Application web.war deployed"
else
echo "Application web.war not available"
fi
JAR Files
How to find a class in a set of JARS recursively
Here is how to search recursively for the class org.jboss.as.ejb3.cache.CacheFactory in the modules folder of the application server
$ grep -r org.jboss.as.ejb3.cache.CacheFactory modules
Binary file modules/system/layers/base/org/jboss/as/ejb3/main/jboss-as-ejb3-<version>.jar matches
How to compile a class adding all the application server JARS in the classpath
$ javac -cp .:`find $JBOSS_HOME -name "*.jar" | tr "\n" ":"` MyClass.java
Server logs
How to read server logs using REST
http://localhost:9990/management/subsystem/logging/log-file/server.log?operation=attribute&name=stream&useStreamAsResponse
How to grep the Server logs for the last hour (ex. find the ERROR String)
$ grep "^$(date -d '-1 hour' +'%H')" /home/jboss/server.log | grep 'ERROR'
How to grep the Server logs for the last minutes (ex. find the ERROR String)
$ sed -n "/^$(date --date='10 minutes ago' '+%H:%M')/,\$p" /home/jboss/log/server.log | grep "ERROR"
How to find which logs files contain a String in the last n days (ex. 5 days)
$ find . -name "server.log*" -mtime -5 | xargs grep -i "OutOfMemoryError"
Clustering
How to check that multicast is working properly (replace the jgroups JAR with the one bundled in your WildFly distribution, under modules/system/layers/base/org/jgroups/main):
$ java -cp jgroups-5.x.y.Final.jar org.jgroups.tests.McastReceiverTest -mcast_addr 224.10.10.10 -port 5555
$ java -cp jgroups-5.x.y.Final.jar org.jgroups.tests.McastSenderTest -mcast_addr 224.10.10.10 -port 5555
How to quickly check which nodes are currently part of the cluster, from the CLI:
/subsystem=jgroups/channel=ee:read-attribute(name=view)
This works the same whether nodes discover each other via UDP multicast, TCPPING, or — the setup you’ll actually run into on Kubernetes/OpenShift, where multicast typically isn’t routed between pods — the KUBE_PING or DNS_PING discovery protocols. See our dedicated article on how to discover JBoss Cluster members for a deeper walkthrough of this command and its output.
JBoss Process
How to find JBoss PID
Option 1)
$ pgrep -f jboss
9156
Option 2)
#! /bin/bash
if [ -z "$(ps -ef | grep org.jboss.Main)" ]
then
echo "jboss is not running"
else
echo "jboss is running"
fi
Option 3) – Needs JDK !
$ jps -lv | grep -i jboss | cut -d ' ' -f 1
9156
How to perform a Thread Dump
Option 1)
$ kill -3 JBOSSPID
Option 2)
$ jstack -l JBOSSPID > jstack.out
Replace JBOSSPID with the Application server’s PID
How to count the number of Threads running
On linux architectures, you can count the number of running threads (as lightweight processes) as follows:
$ ps -eLf | grep [PID] | wc -l
How to check the CPU usage of a Thread
Thread are qualified by Linux Operating system as lightweight processes. You have to execute at first top to retrieve the CPU usage of a Thread Id:
$ top -b -n 1 -H -p JBOSSPID
Example output:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
8374 jboss 25 0 2284m 640m 80m R 39.5 23.7 13:00.64 java
8465 jboss 25 0 2284m 640m 80m R 19.5 23.7 7:23.10 java
Now that you have identified the top CPU consuming Thread ids (Column PID), check their stack trace to see what’s going on
How to monitor the Java Process size (using pmap)
pmap -x <pid>
How to store the amount of RSS (Process Resident Size) of a process in a variable
Assumed that the outout of pmap has been stored in a file named pmap.log:
export JVMSIZE=$(grep "total kB" pmap.log | awk '{print $4}')
How to monitor the Java Native Memory: (Requires JDK!):
Include the following settings in your JDK:
-XX:+UnlockDiagnosticVMOptions -XX:NativeMemoryTracking=detail -XX:+PrintNMTStatistics
Then, execute the following command against the Java PID:
jcmd <pid> VM.native_memory
How to monitor a Java Process Heap size: (Requires JDK!)
jcmd <pid> GC.heap_info
Note: jmap -heap still works on current JDKs, but jcmd <pid> GC.heap_info is the tool the OpenJDK team now recommends for this — it uses the same attach mechanism without the overhead of a full heap connection. Example output:
$ jcmd 713 GC.heap_info
713:
garbage-first heap total 1048576K, used 314214K [0x00000006c0000000, 0x0000000800000000)
region size 1024K, 205 young (209920K), 12 survivors (12288K)
Metaspace used 92104K, committed 93440K, reserved 1179648K
class space used 10943K, committed 11456K, reserved 1048576K
Networking
How to monitor incoming traffic using tcpdump
Example: monitor port 9990
$ tcpdump -A -i lo 'port 9990' -v
Example: monitor port 9990 on host 127.0.0.1:
$ tcpdump -A -i lo 'dst host 127.0.0.1 and dst port 9990' -v
Example: monitor multicast on the current machine:
$ tcpdump -n "multicast"
How to tunnel some ports of the application server with SSH
Example: tunnel port 9990 of the IP Address 192.168.10.1 on localhost (so for example you can reach the remote console with http://localhost:9990)
$ ssh -R 9990:192.168.10.1:9990 user@gateway
How to check ports opened by a JBoss/WildFly process
$ lsof -Pri | grep java
java 9156 francesco 343u IPv4 92363 0t0 TCP localhost.localdomain:8080 (LISTEN)
java 9156 francesco 380u IPv4 92366 0t0 TCP localhost.localdomain:9990 (LISTEN)
How to find which process is engaging my JBoss ports: (e.g. 8080)
Most current distributions (RHEL 9/10, Fedora, recent Ubuntu) no longer ship net-tools by default, so reach for ss from iproute2 instead of netstat — the syntax is close enough that the old habit still helps:
$ ss -tanp | grep 8080
LISTEN 0 128 127.0.0.1:8080 0.0.0.0:* users:(("ssh",pid=3861,fd=6))
Please note that you need a super-user if you want to see all processes running on the machine. In our case the PID is 3861 used by ssh
How to generate a virtual IP Address (Useful for clustering purposes)
ifconfig is deprecated on modern distros; the iproute2 equivalent is:
$ ip addr add 10.0.1.1/24 dev eth0 label eth0:2
IO and Disk Space
How to find the size of a directory, including subdirectories (Especially useful for log files)
$ du -sh standalone/log/
600K standalone/log/
How to find space left on a device
$ df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/fedora-root 50G 27G 20G 58% /
How to compare two files side by side (useful to check differences between configuration files)
$ sdiff -s standalone1.xml standalone2.xml
<connection-url>jdbc:h2:mem:test</connection-url> | <connection-url>jdbc:h2:mem:other</connection-url>
How to find IO statistics per process (useful especially for journal!)
$ cat /proc/4383/io
rchar: 6311275
wchar: 6525
syscr: 3883
syscw: 40
read_bytes: 3129344
write_bytes: 77688832
cancelled_write_bytes: 0
In the above example, we are checking IO statistics of the process id 4383.
Backup and Recovery
How to backup a JBoss installation with rsync
rsync -azR --delete --exclude "data/activemq" --exclude "data/kernel" --exclude "data/timer-service-data" --exclude "data/tx-object-store" --exclude "log/*" --exclude "tmp/*" /home/jboss/wildfly ServerDest:/path
In this example, we are syncing the folder /home/jboss/wildfly to the Host “ServerDest” and path: “path“. Exclude log and tmp files and some data files.
Note: file-level rsync backups are fine for data directories, but for the server installation itself, consider whether a Galleon-based provisioning script (re-creating the exact same server from a versioned feature-pack/layer list) wouldn’t serve you better than a binary copy — it’s reproducible, diffable, and doesn’t carry over any drift that crept into the live install.
Jakarta EE
How to recursively replace all javax occurrences with jakarta in Java classes (needed when moving code to WildFly 27+, which runs on Jakarta EE 10):
find . -name '*.java' | xargs sed -i 's/javax/jakarta/g'
Web services
How to call a REST service with curl using authentication and passing JSON parameters
$ curl -u admin:admin -H "Content-Type: application/json" -d '{"name":"John Doe", "email": "john.doe@jboss.com", "phoneNumber":"11223344"}' http://localhost:8080/restservice
Systemd commands for WildFly admins
If WildFly is installed as a Linux service (rather than a Bootable JAR or a container), you’re managing it through systemd, not by running standalone.sh directly in a terminal. These are the commands you’ll reach for most:
Start, stop, and check the unit status:
$ sudo systemctl start wildfly
$ sudo systemctl stop wildfly
$ sudo systemctl status wildfly
Enable the service to start automatically at boot:
$ sudo systemctl enable wildfly
Tail the server’s output directly through the journal (handy when standalone.sh’s console output is redirected there instead of to a plain log file):
$ journalctl -u wildfly -f
Show only the last hour of logs for the unit, filtered by priority (ex. errors and above):
$ journalctl -u wildfly --since "1 hour ago" -p err
Reload the unit file after editing it, without restarting every service on the box:
$ sudo systemctl daemon-reload
Container (Podman/Docker) commands for WildFly admins
If instead your WildFly instance runs as a container, most of the “find the PID / tail the log” muscle memory above needs a container-aware equivalent:
Tail the logs of a running WildFly container:
$ podman logs -f wildfly-app
Open a shell inside the running container, e.g. to run jboss-cli.sh locally against the admin port:
$ podman exec -it wildfly-app bash
Check the live CPU/memory usage of the container — this is the container-level view that complements jcmd/top run from inside it:
$ podman stats wildfly-app
Copy a thread dump or heap dump out of the container filesystem to the host for offline analysis:
$ podman cp wildfly-app:/opt/jboss/wildfly/jstack.out ./jstack.out
(All four commands work identically with docker in place of podman if that’s your runtime of choice.)
Recommended Articles
Configure WildFly or JBoss as a Service on Linux and Windows: Best Practices & Troubleshooting
Learn how to set up WildFly or JBoss services on Linux and Windows, including best practices, common pitfalls, and native systemd support. #WildFly #JBoss #LinuxService #WindowsService
Discover Where JBoss EAP/WildFly Logs Are Located: Standalone vs Domain Mode
Learn where to find and view logs in JBoss EAP/WildFly, whether running in standalone or domain mode.
Mastering JBoss CLI Scripts for Domain Mode Operations
Learn how to configure resources, reach server nodes, and manage server groups with JBoss CLI scripts in domain mode.
Install WildFly Application Server on Linux and Windows with JDK Support
Learn how to install WildFly application server on Linux and Windows. Includes JDK support and environment variables setup.