With GNU screen (version 4), why is it that the following runs perfectly fine:
$ screen -S some-name
But if I try having a slash (/
) in the session name, it gives me an error about multiuser support.
$ screen -S some/name
Must run suid root for multiuser support.
If I try setting the session name from within the screen:
$ screen
C-a :sessionname some/name
I get the following error:
: bad session name 'some/name'
So apparently a /
is invalid character for a session name. Looking at the man page for screen, I see nothing about invalid or reserved characters for sessionname
:
‘-S sessionname’
Set the name of the new session to sessionname. This option can be used to specify a meaningful name for the session in place of the default tty.host suffix. This name identifies the session for the screen -list and screen -r commands. This option is equivalent to the sessionname command (see Session Name).
8.5 Session Name
— Command: sessionname [name](none)
Rename the current session. Note that for screen -list the name shows up with the process-id prepended. If the argument name is omitted, the name of this session is displayed.
Caution: The $STY environment variable still reflects the old name. This may result in confusion. The default is constructed from the tty and host names.
Also, unmatched '
and "
in the session name complain about unmatched quotes which seems to be about syntax. E.g., :sessionname 'test"'
gives test"
as the name. And ^A
, ^B
, etc. yield control characters.
What is the valid syntax or characters for a session name?
Best Answer
The purpose of assigning a name to a screen session with
-S
is so you can operate on that session (for example withscreen -r ...
) by specifying its name.Looking at the man page under the
-r
option:So a session name with a
/
character is interpreted asowner/name
. (This could be documented better under the-S
option.)You can do
which is equivalent to:
In some quick experiments with screen version 4.01.00, I haven't found any other special characters that are prohibited in session names. All the following:
worked correctly for me.
In the last one, the
^X
was actually a literal Ctrl-X character.screen -ls
shows it literally; I had to doscreen -ls | cat -A
to see it. I was able to resume all these sessions by specifying their names:etc., and the value of
$STY
within each session was correct.(I don't recommend using control characters, for what I hope are obvious reasons.)