3

In bash I can start a named screen by doing

screen -S test

If I type

ctrl-a A new_screen_name

it only changes the title of the screen. When I do a

screen -r

I see the session name is still the same.

2 Answers 2

5

From info screen:

-- 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_: Among other problems, the$STY' environment variable still reflects the old name. Use of this command is strongly discouraged. Use the `-S' commandline option if you need this feature. The default is constructed from the tty and host names.

1
  • Thanks for the answer. The command given in the comment was especially what I needed.
    – D W
    Sep 9, 2010 at 21:28
2

Change name of existing session

You can change the name of an existing session by attaching to the desired session and once inside issuing a shortcut combination and then a command:

CTRL-A 
:sessionname NEW_NAME

If not sure how to do it, below are detailed steps.

First, look for your session ID number:

$ screen -ls
There is a screen on:
    7934.pts-1.myserver (01/14/2014 11:27:25 PM)    (Detached)
1 Socket in /var/run/screen/S-user.

Then attach to your session:

$ screen -r 7934

Press this shorcut combination:

CTRL-A

Now type this command:

:sessionname MYTEST

Of course, change MYTEST for your desired session name. Press enter to perform the change.

Confirm that your session name has changed:

$ screen -ls
There is a screen on:
        7934.MYTEST     (01/14/2014 11:27:25 PM)        (Detached)
1 Socket in /var/run/screen/S-user.

Congratulations!


Assign a name when opening a new session

Choosing a session name when you are creating it for the first time is even simpler. Just use the screen command with -S option followed by the desired name.

Example:

$ screen -S MY_NEW_SESSION

Confirm the name is assigned:

$ screen -ls
There are screens on:
    15832.MY_NEW_SESSION    (01/16/2014 10:08:31 AM)    (Detached)
1 Socket in /var/run/screen/S-user.

That's it!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .