Rename gnu screen session name

Ever wonder how you can rename your screen session name? You are in a hurry make a screen session execute some program and then you decide you want to leave the program executing there, but you named the session something not so informative like nothing (and get the default session name like “5026.pts-5.ubuntu” or similar…) or “test”. So there is an easy way of renaming the screen session name with a simple command of

screen -S <old_session_fullname> -X sessionname <new_session_name>

Here is the example for better clarity! Let’s say we have:

[root@srv ~]# screen -ls
There is a screen on:
        24624.test      (Detached)
1 Socket in /var/run/screen/S-root.

And here is the right renaming command. We want to rename the current gnu screen to “loganalyzing”:

screen -S 24624.test -X sessionname loganalyzing

As you can see you should use the fullname taken from the “screen -ls” command, in newer version you can use only the name like:

screen -S test -X sessionname loganalyzing

And here is the result:

[root@srv ~]# screen -ls
There is a screen on:
        24624.loganalyzing      (Detached)
1 Socket in /var/run/screen/S-root.

GNU Screen with scrolling history under X window system

Screen program is really a good piece of software for every one in the console. We use it every day to execute programs in the “background” or if we want to end our ssh session to the server without stopping our executed program. We need a tiny configuration to use our favorite scrolling of the console program under the X windowing systems!

So if you are under let’s say KDE or Gnome (especially Ubuntu and CentOS) and use konsole or xterm and you want to be able to scroll the history of your ssh sessions, when you start something under gnu screen you must set the following file at your home directory

/home/<your_user>/.screenrc

with this configuration:

termcapinfo xterm* ti@:te@