[This continues my previous question How do I know I'm running inside a linux "screen" or not? ]

As title, can I?

I tried screen -S mysess but it creates a new screen instead of changing the name of current screen.

I also tried screen -X 'sessionname haha' , but no effect. It just display a inverse-color bar at terminal bottom saying

-X: unknown command 'sessionname haha'

enter image description here enter image description here


Use Ctrl-a: to get to command mode for the session and then use the sessionname command

sessionname session1


Using your example above:

If you are detached from a session you can change it's session name with

screen -r 25278.pts-15.linux-ic37 -X sessionname YourSessionName

If you are attached to the session then you can change it's session name with

screen -d -r 25134.pts-3.linux-ic37 -X sessionname YourSessionName
  • Iain, you're like Wikipedia with added mod privileges. That's my cool-thing-I-did-not-know-but-will-use-often-now-I-do for the day, and it's not even 9am yet. Thanks! – MadHatter Apr 6 '12 at 7:50
  • Thank. But I'd like it to be done programmably so to be run from a shell script, not interactively. – Jimm Chen Apr 6 '12 at 8:02
  • 2
    @JunChen: you should have said that in your question then ! – user9517 Apr 6 '12 at 8:09
  • Thank you. I got it now. The single quotes in my command caused the problem. Anyway, I think I have made it clear from the beginning, because from my screenshot, you can see I tried to change the session name via command line. – Jimm Chen Apr 7 '12 at 0:54
  • And I found that, in order to change current session name, just typing screen -X sessionname haha does not always work. On second execution, it will inevitably fail with message like /var/run/uscreens/S-chj2/16218.pts-9.linux-ic37: No such file or directory --still a pending question. – Jimm Chen Apr 7 '12 at 2:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.