mac CLI. I want to run screen but I get "screen Cannot open your terminal '/dev/ttys002'…
- User
mac CLI. I want to run screen but I get
"screen Cannot open your terminal '/dev/ttys002' - please check."
why ?
context: I want to use a user, not root. /dev/ttys002 belongs root. I am connected via ssh
- Assistant
screenneeds read-/write access to the controlling terminal (the device you see in the error message).
If the device is not owned by you – or you are notroot– it refuses to start and you get:Cannot open your terminal '/dev/ttys002' - please check.Why is the tty owned by root?
Typical scenario:
- You ssh in as root (or someone in the wheel group).
- Then you
su otheruser(orsudo -u otheruser …).
‑→ You changed your UID, but the tty is still owned by the account that logged in first (root).
‑→otherusernow lacks permission to open/dev/ttys002.
You can confirm it:
$ who am i bob ttys002 Jun 21 12:34 $ ls -l /dev/ttys002 crw--w---- 1 root tty 0x0200003 Jun 21 12:34 /dev/ttys002root owns the device, group is
tty, and normal users are neither root nor in grouptty.──────────────────────────────────────────────── How to solve / work-around ────────────────────────────────────────────────
Choose whichever fits your workflow best.
-
Log in as the target user directly
ssh otheruser@host # the tty is created with correct ownership screen # works -
Give the user a fresh pseudo-tty inside your current session
su - otheruser # or sudo -u otheruser -i script -q /dev/null # instant new pty that *is* owned by otheruser screen # now worksExit
scriptwith when you’re done with screen. -
Run screen set-uid root (traditional way)
On many Unix systemsscreenis installed setuid-root so it can always open a tty.
Homebrew/macOS ships it without the s-bit for security reasons. If you trust your users:sudo chmod u+s /usr/local/bin/screen # or wherever screen livesNow any user can start
screenregardless of the tty owner.
(Understand the security implications before doing this.) -
Temporarily chown the device (root only)
sudo chown otheruser /dev/ttys002Works but reverts on logout/login and is seldom worth the trouble.
──────────────────────────────────────────────── TL;DR ────────────────────────────────────────────────
screenfails because the tty device belongs to root after you usedsu.
Either log in as the correct user from the start, create a new pty withscript, or installscreensetuid-root.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.