Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

[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

share|improve this question
add comment

1 Answer

up vote 8 down vote accepted

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

sessionname session1

EDIT:

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
share|improve this answer
    
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 ! –  Iain 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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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