I know that I can run tmux -V
to find the version of tmux
that is in my PATH
, but how can I get the version of tmux
that is currently running?
4 Answers
As pointed out in a comment, tmux -V
returns the version:
$ tmux -V
# tmux 1.8
Tested on Centos 7 and OSX 10.11.5.
-
2This should be the selected answer. Also tested this on Amazon Linux 👍 Mar 7, 2017 at 17:34
-
13I don't think this answers the question. I'm not sure why it's rated so highly. That command just returns the version of whatever tmux is in my path.– quantMar 25, 2017 at 0:29
-
5It's because this shows up as the first result of How to get tmux version. Aug 21, 2017 at 22:56
-
1
-
1@ssi-anik: It appeared to work. That switch was added at a certain point, so it began to work to show you the first installed version found in your PATH, which is not necessarily the same as the version you're running. As time goes by you're less and less likely to run into versions of
tmux
not supporting-V
, and most of the time you aren't likely to be running one version and having another that appears first in your PATH. But if you really specifically want to know the currently running version, then this is not reliable for 2 reasons. Feb 28 at 19:41
Most obvious, but not 100% correct way is to execute this command in console
$ tmux -V
and receive output like this tmux 2.9a
with version of tmux INSTALLED, not currently running.
In 99% cases it is enough, but there can be subtle nuances.
Command tmux -V
will return version of tmux installed at /usr/bin/tmux or any other directory inside your PATH variable. If you have tmux already running, it is possible that tmux can be started from binary of other version and from different place (for example, tmux can be started from /home/user/bin/tmux
).
In this case, you have to call
$ ps -e | grep tmux
to see PID of all tmux processes currently running. It will output something like this
[vodolaz095@ivory ~]$ ps -e | grep tmux
19699 pts/0 00:00:00 tmux: client
19701 ? 00:00:00 tmux: server
Here, number 19701 depicts process id (PID) of currently running tmux server.
After getting PID of tmux server, you can ran command
$ lsof -p 19701
to get information about CURRENTLY RUNNING tmux server process (in my case its 19701) that will output something like this (Figure 1)
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
tmux:\x20 19701 vodolaz095 cwd DIR 8,33 4096 22544385 /home/vodolaz095
tmux:\x20 19701 vodolaz095 rtd DIR 8,1 4096 2 /
tmux:\x20 19701 vodolaz095 txt REG 8,1 677760 3675332 /usr/bin/tmux
tmux:\x20 19701 vodolaz095 mem REG 8,1 6406312 131327 /var/lib/sss/mc/group
as you can see, tmux currently running was executed from binary placed in /usr/bin/tmux.
Or, you can call one liner
lsof -p `pgrep 'tmux: server'`
to achieve the same output as Figure 1
After you get path to tmux binary CURRENTLY RUNNING, (in my case, it was /usr/bin/tmux
), you can execute this binary with flag -V to get its version
/usr/bin/tmux -V
or, if tmux was installed by limited user into /home/user/bin/tmux
,
/home/user/bin/tmux -V
And, as result, you'll get version of tmux currently running, not the one, that was installed.
-
8It's worth mentioning that this won't work if
tmux
has been upgraded since the given process was started.– nobodyNov 2, 2014 at 23:41 -
3
-
56
-
1this method will require you to execute tmux first; instead you could use
which tmux
to find out the path– ShivaJul 6, 2016 at 6:12 -
1@Shiva - question author said "version of tmux that is currently running?" - so tmux is running already May 6, 2017 at 6:57
To get the version of the tmux server you can use display-message.
./tmux2.3 display-message -p "#{version}"
Will show the version of the server (2.7 in my case)
-p will direct the output of stdout so you can script with it and {version} can be anything from the FORMATS section in the man page.
The following will give you the executable of your tmux server, on linux:
realpath /proc/$(tmux display-message -p "#{pid}")/exe
And on macos, proc_pidpath
can be used, see https://stackoverflow.com/a/8149380
-
The
/proc
hack is Linux only (and possibly Solaris etc; but not generally portable)– tripleeeJun 6, 2019 at 4:43 -
display-message is the perfect solution for getting the server version! Jan 29, 2020 at 19:35
-
-
4In a running tmux client, you can do
:display-message -p "#{version}"
Sep 23, 2020 at 17:35 -
2@quant This should be the selected answer since the display-message approach actually returns the actively running tmux version and as pointed out that could differ from the currently installed one if there was an update after starting the instance. Alltough I simply run "display-message -p "#{version}" in tmux itself using <prefix>: as oposed to calling the binary.– MemphiZApr 24, 2021 at 18:57
To find the actual version of the tmux that is running, you have to find the PID of the tmux:
pgrep tmux
With this info, you can check the version by running:
lsof -p $tmuxPID | grep REG | grep -i -e deleted -e "tmux$"
If there is not a (deleted) next to the tmux file listed, you can just run that file with a -V
.
If it results in files that are "(deleted)", you are running an old, uninstalled version. If you are on linux, you can figure out what it is by running:
/proc/$tmuxPID/exe -V`
If you are on OS X, you are stuck with whatever information is in the path to the filename, possibly something like Cellar/tmux/<version number>/bin/tmux
.
You can combine many of these steps into the following one-liner:
for tmuxPID in $(pgrep tmux); do lsof -p $tmuxPID | grep REG | grep -i -e deleted -e "tmux$"; done
Or if you are on Linux, this always works:
for tmuxPID in $(pgrep tmux); do /proc/$tmuxPID/exe -V; done