When attempting to run tmux as a non-root user, you may encounter the following error:
create session failed: : No such file or directory
The most effective way to diagnose this issue is using strace:
strace -f -e trace=file tmux
This typically reveals permission problems with pseudo-terminal devices:
open("/dev/ptmx", O_RDWR) = -1 EACCES (Permission denied)
open("/dev/ptyp0", O_RDWR) = -1 EACCES (Permission denied)
...
open("/dev/ptyq0", O_RDWR) = -1 ENOENT (No such file or directory)
The issue stems from incorrect permissions on the pseudo-terminal devices in /dev. These devices are crucial for terminal multiplexers like tmux to function properly.
There are several approaches to resolve this:
1. Check and Fix Device File Permissions
ls -l /dev/ptmx /dev/pts/
sudo chmod 666 /dev/ptmx
sudo chmod g+rw /dev/pts/*
2. Verify the pts Group
Ensure your user is in the correct group:
groups
sudo usermod -a -G tty $(whoami)
sudo usermod -a -G pts $(whoami)
3. Check udev Rules (System-specific)
For systems using udev, verify the rules:
cat /etc/udev/rules.d/* | grep pty
To make the changes permanent, create a udev rule:
echo 'KERNEL=="ptmx", MODE="0666"' | sudo tee /etc/udev/rules.d/99-ptmx.rules
sudo udevadm control --reload-rules
After implementing the changes, verify tmux works:
tmux new-session -d -s test_session
tmux ls
If permission changes aren't possible, consider:
- Using screen instead of tmux
- Running tmux in a container with proper permissions
- Configuring sudo rules for specific tmux commands
When attempting to run tmux as a non-root user on your VPS, you're encountering the frustrating error:
create session failed: : No such file or directory
Through strace diagnostics (strace -f -e trace=file tmux
), we can see the underlying issue is permission denial on pseudo-terminal devices:
32000 open("/dev/ptmx", O_RDWR) = -1 EACCES (Permission denied)
32000 open("/dev/ptyp0", O_RDWR) = -1 EACCES (Permission denied)
Modern Linux systems handle pseudo-terminals through two mechanisms:
1. The legacy BSD-style /dev/pty* devices
2. The newer Unix98 /dev/ptmx device
Your system appears to have restrictive permissions on these critical devices. Let's verify the current permissions:
ls -l /dev/ptmx
ls -l /dev/pts/
First, check and potentially fix the device group ownership:
sudo chmod 666 /dev/ptmx
sudo chown root:tty /dev/ptmx
For modern systems using devpts, ensure proper mount options in /etc/fstab:
devpts /dev/pts devpts gid=5,mode=620 0 0
After making changes, verify with:
tmux new -s test_session
echo $?
Successful execution should return exit code 0. If problems persist, check kernel messages:
dmesg | grep -i pty
If you can't modify system permissions, consider these workarounds:
# Run tmux through sudo with proper permissions
sudo -u your_user tmux
# Or create an alias in ~/.bashrc
alias tmux='sudo -u $(whoami) tmux'
On modern systems using SystemD, you might need to check:
systemctl status systemd-udevd
journalctl -u systemd-udevd
Look for any errors related to device creation or permissions.