Unix & Linux Stack Exchange
Q&A for users of Linux, FreeBSD and other Unix-like operating systems
Latest Questions
2
votes
1
answers
30
views
SSH multiplexing + control master when network connection changes
I have a computer server and a laptop guest, both running Ubuntu. I set SSH multiplexing and control master in the laptop's `.ssh/config` like the following: Host servername User username Port 22 HostName servername.ddns.net ControlMaster auto ControlPersist 1h ControlPath /tmp/ssh_mux_%r@%n:%p When...
I have a computer server and a laptop guest, both running Ubuntu.
I set SSH multiplexing and control master in the laptop's
.ssh/config
like the following:
Host servername
User username
Port 22
HostName servername.ddns.net
ControlMaster auto
ControlPersist 1h
ControlPath /tmp/ssh_mux_%r@%n:%p
When the laptop connects to the server via ssh servername.ddns.net
, a control file is created. However, if the laptop exists the connection to the server and tries to connect again while using a different Wifi network, the ssh attempt hangs. I suppose because there's some conflict with the control file that was created originally.
How could I set up SSH multiplexing and control master in a way that is robust to connecting and re-connecting to the server using different WiFi networks?
hannah
(21 rep)
Jun 26, 2025, 10:32 AM
• Last activity: Jun 26, 2025, 10:51 AM
311
votes
9
answers
178629
views
How to create a new window on the current directory in tmux?
Is is possible to open a `new-window` with its working directory set to the one I am currently in. I am using *zsh*, if it matters.
Is is possible to open a
new-window
with its working directory set to the one I am currently in. I am using *zsh*, if it matters.
sharat87
(4439 rep)
Apr 26, 2011, 10:25 AM
• Last activity: Jan 2, 2025, 02:32 AM
0
votes
1
answers
447
views
Open a new window in tmux only if no window is opened in the given path, otherwise attach to it
Currently I have my terminal (`alacritty`) run `tmux new -A -s 0` at start to start a new session `0`, or attach to it if it already exists. One problem is, I sometimes use open in directory from file manager (Dolphin). In that case, I am just reconnected to the older session and not in the desired...
Currently I have my terminal (
alacritty
) run tmux new -A -s 0
at start to start a new session 0
, or attach to it if it already exists. One problem is, I sometimes use open in directory from file manager (Dolphin). In that case, I am just reconnected to the older session and not in the desired directory.
What I want to achieve is to open a new window in the session 0
with my desired path as working directory if no such window exists in the given session. Otherwise, I want to switch to that existing window.
If that is not possible, I'm happy with just creating a new window every time. Maybe it can be detected if a process is running in the current active window, and if not, using cd
to switch the directory?
If anyone has any ideas on how to achieve this, it will be greatly appreciated.
Sntn
(123 rep)
Mar 12, 2024, 08:09 AM
• Last activity: Mar 13, 2024, 07:34 AM
1
votes
2
answers
1591
views
How to equalize byobu vertical split screen size
Note: I may be leaning on an [XY Problem][1]; feel free to steer me to a more ideal approach. > I want to keep an eye on multiple remote log files in a small-yet-legible font, **not so much analyzing content as peripherally noticing sudden bursts in activity**. I'm trying to create a Byobu script to...
Note: I may be leaning on an XY Problem ; feel free to steer me to a more ideal approach.
> I want to keep an eye on multiple remote log files in a small-yet-legible font,
**not so much analyzing content as peripherally noticing sudden bursts in activity**. I'm trying to create a Byobu script to tail log files on six remote servers.
I'm used to Vim, but Byobu calls it a vertical split:
Scripted splits chop existing terminals in half, rendering each split smaller, leading to
I'm new to Byobu. There's surely a way to select a different pane, execute a command, then split, but I can't seem to get the syntax (order?) right.
I expect there's also a command to just "equalize" all panes at once. That would be even more handy.
This question has the manual, unscripted version of what I need.
Years ago I used GNU screen similarly, and it worked great--except using a GUI all day conditions me to use the mouse, so switching between terminals feels clunky. Maybe screen is still the smartest solution. Or tmux? I'm not married to Byobu's chyron readout.
As windows split they divide by 50%, so I'm willing to accept eight terminals if the even halving leads to a smoother execution.
Thanks in advance--any thoughts?
**not so much analyzing content as peripherally noticing sudden bursts in activity**. I'm trying to create a Byobu script to tail log files on six remote servers.
I'm used to Vim, but Byobu calls it a vertical split:

create pane failed: pane too small
and a window with vanishing perspective:

zedmelon
(155 rep)
Jun 25, 2019, 01:51 AM
• Last activity: Feb 12, 2024, 01:07 AM
209
votes
10
answers
83538
views
tmux vs. GNU Screen
[Browsing through questions][1] I found about tmux (I normally used GNU Screen). My question is what are pros and cons of each of them. Especially I couldn't find much about tmux. [1]: https://unix.stackexchange.com/questions/479/keep-ssh-sessions-running-after-disconnection
Browsing through questions I found about tmux (I normally used GNU Screen). My question is what are pros and cons of each of them. Especially I couldn't find much about tmux.
Maja Piechotka
(16936 rep)
Aug 16, 2010, 10:33 PM
• Last activity: Oct 24, 2023, 02:29 PM
1
votes
2
answers
788
views
Does any terminal multiplexer (screen, tmux, zellij) support job suspension (Ctrl-Z) in Bash?
As far as I've seen, pressing Ctrl-Z on any terminal multiplexer, or trying to start them in the background, does nothing or crashes. I know that, in a sense, terminal multiplexers are a "replacement" for job control, and usually, they have their own mechanisms for suspending and resuming. Still, I...
As far as I've seen, pressing Ctrl-Z on any terminal multiplexer, or trying to start them in the background, does nothing or crashes.
I know that, in a sense, terminal multiplexers are a "replacement" for job control, and usually, they have their own mechanisms for suspending and resuming. Still, I was wondering if I could integrate them in some way into a workflow based on the shell's job control.
**Answer:**
- Screen suspends with "C-a z"
- Tmux suspends with "C-b C-z"
- Zellij suspends with "C-o d", but unlike the previous ones, it doesn't place the process on the shell's job control.
Sebastian Carlos
(262 rep)
Jul 13, 2023, 10:06 AM
• Last activity: Jul 13, 2023, 01:36 PM
1
votes
0
answers
1034
views
tmux 1 session accessed by multiple terminals, each with a different visual state
I use a tiling window manager and someimtes have 6 or 7 shells open at once. Locally, I use tmux purely as a multiplexer because my preferred terminal does not have one (which I like). I would like each terminal that I open to access the same tmux session (which I have working), and I want to assign...
I use a tiling window manager and someimtes have 6 or 7 shells open at once. Locally, I use tmux purely as a multiplexer because my preferred terminal does not have one (which I like). I would like each terminal that I open to access the same tmux session (which I have working), and I want to assign each terminal to a different window (1-9) in the same session. However, if I open two different terminals that share the same session, any visual state change to one will affect the other. For example, if I move one terminal to window 2 the other terminal will also move to window 2. This makes sense, but I want it to not be that way.
How can I get each terminal to share the same session but have independent visual states? If this is not possible, do you have any suggestions that are close to my intended workflow?
marc.soda
(203 rep)
Nov 17, 2022, 05:17 AM
1
votes
1
answers
965
views
How do I get a tmux session's base directory?
I have been using `tmux` for a few months, and there is one thing that always bothered me: when I type `cd` into my shell, I get moved into my home directory (this is the standard behavior of `cd`, so nothing unexpected). What I would like to have is that I get into the current tmux session's base d...
I have been using
tmux
for a few months, and there is one thing that always bothered me: when I type cd
into my shell, I get moved into my home directory (this is the standard behavior of cd
, so nothing unexpected).
What I would like to have is that I get into the current tmux session's base directory, and this could probably easily be implemented via a shell function:
cd () {
if [ $# -eq 0 ]
then
command cd $TMUX_BASE_DIR # fictional environment variable
else
command cd $@
}
However, I have not found a way to find this directory. tmux does not have a build-in command apparently nor sets an environment variable. I also skimmed over the man page, but didn't find anything in the COMMANDS
or VARIABLES
section. This directory needs to be saved somewhere though, as opening a new tmux window makes it go to this directory.
Of course one I open a new window and close one everytime I want to achieve the desired behavior, but this is surely less than optimal and there needs to be a better way.
Is there a way to achieve this behavior / get the session base directory in tmux? If so, how?
leo848
(111 rep)
Nov 12, 2022, 02:58 PM
• Last activity: Nov 12, 2022, 03:57 PM
31
votes
2
answers
30230
views
Set the active tmux tab color
Is it possible to change the background of the active (current) tmux tab? I'm using `tmux 1.9` on Ubuntu 15.04. $ tmux -V tmux 1.9 I tried to do: set-option -g pane-active-border-fg red But the result was not changed: ![][1] I expected the `3-bash*` to have a red background. [1]: https://i.sstatic.n...
Is it possible to change the background of the active (current) tmux tab?
I'm using
I expected the
tmux 1.9
on Ubuntu 15.04.
$ tmux -V
tmux 1.9
I tried to do:
set-option -g pane-active-border-fg red
But the result was not changed:

3-bash*
to have a red background.
Ionică Bizău
(3481 rep)
Jun 17, 2015, 07:56 AM
• Last activity: Jan 7, 2022, 09:34 AM
1
votes
1
answers
996
views
Execute command when creating new screen session
With the `screen` command, the `-X` option allows you to execute a command in the specified screen session, but when you try to use it when creating a *new* screen, e.g: ``` screen -dmS -S downloader -X "wget https://google.com" ``` you get the error `No screen session found.`. So it's clear the the...
With the
screen
command, the -X
option allows you to execute a command in the specified screen session, but when you try to use it when creating a *new* screen, e.g:
screen -dmS -S downloader -X "wget https://google.com "
you get the error No screen session found.
. So it's clear the the -X
option only works for pre-existing screen sessions.
Is it possible to specify a command to be run on the creation of a *new screen*? If it's not possible in screen
, is it possible in another multiplexer like tmux
?
pigeonburger
(179 rep)
Aug 23, 2021, 11:41 PM
• Last activity: Aug 23, 2021, 11:48 PM
7
votes
1
answers
4178
views
What are the advantages of hardware-accelerated terminal emulators?
> What distinguishes [kitty][1] from the vast majority of terminal emulators? > It offers GPU-acceleration combined with a wide feature set. It’s > targeted at power keyboard users. It’s billed as a modern, hackable, > featureful, OpenGL based terminal emulator. What are the advantages of hardware-a...
> What distinguishes kitty from the vast majority of terminal emulators?
> It offers GPU-acceleration combined with a wide feature set. It’s
> targeted at power keyboard users. It’s billed as a modern, hackable,
> featureful, OpenGL based terminal emulator.
What are the advantages of hardware-accelerated terminal emulators? Is it speed? How you notice that in daily command execution? Classic terminals seem not too slow, the bottleneck is mostly the human typing.
Sybil
(1983 rep)
Jul 16, 2021, 04:48 PM
• Last activity: Jul 16, 2021, 05:13 PM
0
votes
1
answers
4399
views
How to execute a command in tmux and detach using a single line command?
How can I get tmux to execute a command and then detach (That is, automatically in a single line without further input beyond initially starting the session)? I don't know to write sophisticated scripts. But I used to do this in screen with a command like: ```screen -S torrent -d -m qbittorrent-nox...
How can I get tmux to execute a command and then detach (That is, automatically in a single line without further input beyond initially starting the session)?
I don't know to write sophisticated scripts. But I used to do this in screen with a command like:
-S torrent -d -m qbittorrent-nox
But I have been reading that tmux is better and I would like to switch. But I couldn't figure out how to achieve what the above command does.
deadrat
(11 rep)
Jun 19, 2021, 05:28 PM
• Last activity: Jun 21, 2021, 01:49 PM
22
votes
5
answers
8594
views
Does a terminal multiplexer have any benefit when used with a tiling window manager?
Both terminal multiplexers (screen, tmux) and keyboard-driven tiling window managers (ratpoison, dwm, xmonad) provide similar functionality. Is there any benefit in using both at the same time? What about problems that may arise?
Both terminal multiplexers (screen, tmux) and keyboard-driven tiling window managers (ratpoison, dwm, xmonad) provide similar functionality. Is there any benefit in using both at the same time? What about problems that may arise?
Pubby
(323 rep)
May 16, 2012, 05:13 AM
• Last activity: May 20, 2021, 03:52 AM
0
votes
1
answers
789
views
:How to change `Prefix :` (command prompt) to `Prefix ;` in tmux?
I tried to change from `prefix - :` to `prefix - ;` in tmux and it doesn't seem to work. Edit 1: Explanation For a tmux prompt you hit, `prefix` then `:` (*i.e* `shift` + `;`). I want to change it to , `prefix` then `;` (*i.e* just `;`).
I tried to change from
prefix - :
to prefix - ;
in tmux and it doesn't seem to work.
Edit 1:
Explanation
For a tmux prompt you hit, prefix
then :
(*i.e* shift
+ ;
).
I want to change it to , prefix
then ;
(*i.e* just ;
).
TUSqasi
(111 rep)
Oct 19, 2020, 02:01 PM
• Last activity: Dec 18, 2020, 04:13 AM
0
votes
1
answers
142
views
Are there tools that I can use to obtain a snapshot of terminal or pty state?
Please stop marking this question as a duplicate, it's not a duplicate. Thanks. Consider the sequence of `a`, followed by `\x1b[D` ("cursor back"), followed by `b`. This would produce an output of just `b`. ------ I am looking to experiment with and create TUI applications (examples: less, vim), e.g...
Please stop marking this question as a duplicate, it's not a duplicate. Thanks. Consider the sequence of
a
, followed by \x1b[D
("cursor back"), followed by b
. This would produce an output of just b
.
------
I am looking to experiment with and create TUI applications (examples: less, vim), e.g. using ncurses style libraries or with raw application of escape sequences.
I've found that as a tmux user, tmux offers a very useful capture-pane
feature which could be a good basis for a test framework that can use this as a form of "screenshot" functionality for test verification purposes. For example, rather than manually testing the output for correctness and, say, establishing a test that runs the program under test for a specific window size and then comparing the output with a rigid string compare, I could instead run it under tmux through a wide range of window dimensions and check the rendered state to satisfy requirements in a practical way.
Anyway, the point is that this seems to be the only way I know of to "resolve" a terminal byte stream into a terminal screen buffer. As great and versatile as tmux is, I'm somewhat hoping for a tool that provides this specific capability. Since I read some more today about what ptys are and how they work [here](http://www.linusakesson.net/programming/tty/index.php) , it does seem to me that this aspect of the system is in the purview of the terminal emulator, and something like tmux is rather unique in that it has to do it while not being a GUI application (which is a plus here).
Steven Lu
(2422 rep)
Nov 13, 2020, 11:42 PM
• Last activity: Nov 17, 2020, 07:02 PM
1
votes
1
answers
949
views
Mosh and terminal multiplexing
Reading this Q&A on the site: [Can I re-attach to a mosh session?][1] made me wonder about the use cases for `mosh`. Say I start `tmux` on my local client, and then `mosh` to a remote host from within `tmux`. From this `mosh` session, I start a long process on the remote machine that e.g. prints inf...
Reading this Q&A on the site: Can I re-attach to a mosh session? made me wonder about the use cases for
mosh
.
Say I start tmux
on my local client, and then mosh
to a remote host from within tmux
. From this mosh
session, I start a long process on the remote machine that e.g. prints info over time to stdout.
Say that I then lose connectivity on my client, or that I restart my local client (for whatever reason). Will I be able to (1) re-attach to my local tmux session, (2) **still** see my mosh connection alive, and (3) still the server process running and displaying its output in it?
Amelio Vazquez-Reina
(42851 rep)
Dec 29, 2014, 04:17 PM
• Last activity: Aug 29, 2020, 07:03 PM
0
votes
0
answers
125
views
duplicated history entries at the same timestamp
For some time I had an issue with my `history` using GNU `bash` (version 4 and 5) where commands appeared in duplicates. I assumed this was due to the fact that in my `.bashrc` I had the following line: PROMPT_COMMAND="history -a; history -n; $PROMPT_COMMAND" and since I'm using terminal multiplexer...
For some time I had an issue with my
history
using GNU bash
(version 4 and 5) where commands appeared in duplicates. I assumed this was due to the fact that in my .bashrc
I had the following line:
PROMPT_COMMAND="history -a; history -n; $PROMPT_COMMAND"
and since I'm using terminal multiplexers (screen
and/or tmux
) the above mentioned command gets executed several times (therefore echo $PROMPT_COMMAND
results in history -a; history -n; history -a; history -n;
In some situations (especially when doing stuff concomitantly on different panes/windows/frames/buffers) the last command I entered was stored twice or even more often in my ~/.bash_history
. This led to entries like the following:
#1596110297
yadm list -a | xargs -t ls -l
yadm list -a | xargs -t ls -l
Needless to say, this is pretty annoying. I hoped I found a fix for the issue by changing the command to PROMPT_COMMAND="history -a; history -n
but this did not solve it.
Any ideas why that is the case and what I could do get rid of it?
---
Disclaimer: I posted parts of this question at https://unix.stackexchange.com/questions/604842/grep-for-lines-not-after-a-pattern (since I thought the above mentioned solution would work and I therefore only wanted to only get rid of the duplicated entries).
n0542344
(416 rep)
Aug 24, 2020, 12:09 PM
• Last activity: Aug 24, 2020, 10:57 PM
29
votes
1
answers
9354
views
How to copy from/to the tmux 'clipboard' with shell pipes?
When working in a shell environment I run fairly often into the need to copy 'intermediate pipe output' around (eg. from/to already running editors, to other shells, other machines, etc.). When in a windowing environment, an easy (and generic) method to solve this is often via the system clipboard,...
When working in a shell environment I run fairly often into the need to copy 'intermediate pipe output' around (eg. from/to already running editors, to other shells, other machines, etc.).
When in a windowing environment, an easy (and generic) method to solve this is often via the system clipboard, eg.:
* X11:
... | xsel -i
/ xsel -o | ...
* OS X: ... | pbcopy
/ pbpaste | ...
How can I get similarly convenient behavior using the tmux copy/paste facility?
unthought
(971 rep)
Nov 23, 2012, 03:17 PM
• Last activity: Jun 16, 2020, 11:41 AM
1
votes
1
answers
1391
views
tmux copy is slow on macOS
I am having this issue for about 2 years now (since I started to use tmux in Summer 2018) and I have not found a solution to this problem. Any help is greatly appreciated! The copy functionality of tmux is slow. Often times when I copy using mouse selection, and then I paste in the terminal it almos...
I am having this issue for about 2 years now (since I started to use tmux in Summer 2018) and I have not found a solution to this problem. Any help is greatly appreciated!
The copy functionality of tmux is slow. Often times when I copy using mouse selection, and then I paste in the terminal it almost always pastes what I thought was in the clipboard previously, it never copied the current mouse over selection into the clipboard. I have to select and then wait for a bit (usually a second or so).
I am so used to the copy current mouse selection from linux, iTerm2 on macOS and they are blazingly fast, I never have to think about or wait for the selection to be copied.
This causes problems because sometimes my clipboard has sentences and when I mouse over let's say a dir path/filename/git commit hash, etc. and paste in the terminal thinking that a dir path/filename/git commit hash will be pasted, here comes a barrage of sentences.
I have tried a few ways to address this problem none of them to my satisfaction.
1. I tried to print a message after the copy was done:
bind -T copy-mode-vi Tab send -X copy-pipe "reattach-to-user-namespace pbcopy"\; display-message "copied to system clipboard"
2. I saw the mistake I was doing with calling reattach-to-use-namespace every time on selection, so instead, I started tmux only once with this program:
set-option -g default-command "reattach-to-user-namespace -l bash"
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe "pbcopy" \; display-message "copied to system clipboard"
3. Later I switched to tmux-plugins/tmux-sensible which starts tmux with reattach-to-user-namespace.
4. And now a few weeks back I disabled all the bind-key copy configuration and switched to tmux-plugins/tmux-yank . I prefer the tmux-yank configuration better than what I had. But the slowness or delay in copying still persists, I am often pasting the wrong information, thinking the mouse selection is copied into the system clipboard.
I also running updated software as much as possible, hoping to see some improvements. The issue is I do not where the problem is to debug further. Is the slowness in tmux or reattach-to-user-namespace or Alacritty or OS X.
I tried switching back to iTerm2 because this issue was getting annoying but after using Alacritty , iTerm2 is sluggish and slow, as I am streaming a lot logs in the terminal for debugging. And unfortunately Alacritty does not support multi-window mode or tabs at the moment.
Alacritty+tmux on macOS is the perfect solution at the moment for me, except for this once annoyance with the slowness in copy.
I am running:
- tmux 3.1b
- reattach-to-user-namespace 2.8
- alacritty 0.4.2 (f68de37)
- macOS Catalina 10.15.4
I ran into this https://github.com/alacritty/copypasta , I want to give this a try and see if this improves the situation.
And just for writing this question, I pasted the wrong info many times and had to go back and wait for the copy to properly finish.
krafts
(35 rep)
May 27, 2020, 03:55 PM
• Last activity: May 27, 2020, 04:17 PM
0
votes
1
answers
826
views
How to stop terminal from getting mouse click input?
I was just reading this [forum][1] where I found a curious terminal control escape sequence: "\033[?1000h". Naturally, I've tried it to see what could happens. In accordance with the inspiring comment, my terminal started to show chars corresponding to mouse clicks! (Amazing!) **Questions: 1** The "...
I was just reading this forum where I found a curious terminal control escape sequence: "\033[?1000h". Naturally, I've tried it to see what could happens. In accordance with the inspiring comment, my terminal started to show chars corresponding to mouse clicks! (Amazing!)
**Questions: 1** The "entity" mainly responsible for this (terminal showing mouse clicks code) is the line discipline, right? who caughts the sequence and configure the terminal line for this behavior. In this case, normally does it receive mouse inputs and ignore it or does it "subscribe" itself to acess such information?
**Questions: 2** Is it possible to get mouse coordinates in a equivalent form? How?
**Questions: 3** How do I turn it off!? (closing and opening a new terminal deeply dishonors me!)
Thanks in advanced.
I'am using Debian 9, Xterm.
Daniel Bandeira
(152 rep)
May 21, 2020, 12:04 AM
• Last activity: May 21, 2020, 01:26 AM
Showing page 1 of 20 total questions