Tmux executed as root gives me trouble

tmux doesn’t start properly, when I start it as root like so:

truenas_admin@qnaptruenas[~]$ sudo -s
[sudo] password for truenas_admin: 
root@qnaptruenas[/home/truenas_admin]# tmux
[exited]
root@qnaptruenas[/home/truenas_admin]# 1;2c0;276;0c10;rgb:ffff/ffff/ffff11;rgb:0000/0000/0000
zsh: command not found: 1
zsh: command not found: 2c0
zsh: command not found: 276
zsh: command not found: 0c10
zsh: no such file or directory: rgb:ffff/ffff/ffff11
zsh: no such file or directory: rgb:0000/0000/0000
root@qnaptruenas[/home/truenas_admin]#

The characters 1;2c0;276;0c10;rgb:ffff/ffff/ffff11;rgb:0000/0000/0000 ended up on the command line automatically, after tmux exited.

My workaround has been to tmux first and then do sudo -s inside the tmux session.

Just tried this on my master build VM and no issues:

truenas_admin@truenas[~]$
truenas_admin@truenas[~]$ sudo -s
[sudo] password for truenas_admin:
root@truenas[/home/truenas_admin]# tmux
[exited]
root@truenas[/home/truenas_admin]#

Probably worth launching tmux -vv and seeing if the tmux logs it writes have anything interesting.

1 Like

Thanks for that tip!

root@qnaptruenas[/home/truenas_admin]# tmux -vv
sudo: argv[0] mismatch, expected "/usr/bin/zsh", got "-zsh"
[exited]
root@qnaptruenas[/home/truenas_admin]# 1;2c0;276;0c10;rgb:ffff/ffff/ffff11;rgb:0000/0000/0000

That makes me think that 1;2c0;276;0c10;rgb:ffff/ffff/ffff11;rgb:0000/0000/0000 are setup parameters for the tmux session.

There must be some misconfiguration in an init file of sorts. I just don’t know, where to find it, much less to fix it.

Interesting, are you on EE? This has been reported before, but a long time ago. Looks pretty much the same.

1 Like

I’m seeing that same behavior in 25.10.1:

qe-realmini% sudo -s
[sudo] password for testing: 
root@qe-realmini[/mnt/tank/testing]# tmux -vv
sudo: argv[0] mismatch, expected "/usr/bin/zsh", got "-zsh"
[exited]
root@qe-realmini[/mnt/tank/testing]# 1;2c0;276;0c10;rgb:ffff/ffff/ffff11;rgb:0000/0000/0000

But not in 26-BETA.1:

truenas_admin@truenas[~]$ sudo -s
[sudo] password for truenas_admin: 
root@truenas[/home/truenas_admin]# tmux -vv
[exited]
root@truenas[/home/truenas_admin]# 

It may just be that the upstream bug was resolved between the Debian versions each is based on.

This is related to a known bug in sudo that was fixed in debian trixie.

3 Likes