[linux] How to assign name for a screen?

I'm using the screen multiplexer tool on the command shell and open a lot of screens. I then forget which process ID associates with which task.

I would like to set a name for a screen but can't find an option in the manpage.

Currently, listing the screens looks like this:

There are screens on:
    5422.pts-1.aws1 (Detached)
    5448.pts-1.aws1 (Detached)
    5027.pts-1.aws1 (Detached)
3 Sockets in /var/run/screen/S-sb.

And I would like to see something like this:

There are screens on:
    5422.logCleanWorker (Detached)
    5448.overNightLongTask(Detached)
    5027.databaseOverNightLongTask (Detached)
3 Sockets in /var/run/screen/S-sb.

How can I do this?

This question is related to linux unix shell gnu-screen

The answer is


The easiest way use screen with name

screen -S 'name' 'application'
  • Ctrl+a, d = exit and leave application open

Return to screen:

screen -r 'name'

for example using lynx with screen

Create screen:

screen -S lynx lynx

Ctrl+a, d =exit

later you can return with:

screen -r lynx

To create a new screen with the name foo, use

screen -S foo

Then to reattach it, run

screen -r foo  # or use -x, as in
screen -x foo  # for "Multi display mode" (see the man page)

As already stated, screen -S SESSIONTITLE works for starting a session with a title (SESSIONTITLE), but if you start a session and later decide to change its title. This can be accomplished by using the default key bindings:

Ctrl+a, A

Which prompts:

Set windows title to:SESSIONTITLE

Change SESSIONTITLE by backspacing and typing in the desired title. To confirm the name change and list all titles.

Ctrl+a, "


I am a beginner to screen but I find it immensely useful while restoring lost connections. Your question has already been answered but this information might serve as an add on - I use putty with putty connection manager and name my screens - "tab1", "tab2", etc. - as for me the overall picture of the 8-10 tabs is more important than each individual tab name. I use the 8th tab for connecting to db, the 7th for viewing logs, etc. So when I want to reattach my screens I have written a simple wrapper which says:

#!/bin/bash
screen -d -r tab$1

where first argument is the tab number.


Examples related to linux

grep's at sign caught as whitespace How to prevent Google Colab from disconnecting? "E: Unable to locate package python-pip" on Ubuntu 18.04 How to upgrade Python version to 3.7? Install Qt on Ubuntu Get first line of a shell command's output Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running? Run bash command on jenkins pipeline How to uninstall an older PHP version from centOS7 How to update-alternatives to Python 3 without breaking apt?

Examples related to unix

Docker CE on RHEL - Requires: container-selinux >= 2.9 What does `set -x` do? How to find files modified in last x minutes (find -mmin does not work as expected) sudo: npm: command not found How to sort a file in-place How to read a .properties file which contains keys that have a period character using Shell script gpg decryption fails with no secret key error Loop through a comma-separated shell variable Best way to find os name and version in Unix/Linux platform Resource u'tokenizers/punkt/english.pickle' not found

Examples related to shell

Comparing a variable with a string python not working when redirecting from bash script Get first line of a shell command's output How to run shell script file using nodejs? Run bash command on jenkins pipeline Way to create multiline comments in Bash? How to do multiline shell script in Ansible How to check if a file exists in a shell script How to check if an environment variable exists and get its value? Curl to return http status code along with the response docker entrypoint running bash script gets "permission denied"

Examples related to gnu-screen

How do I force detach Screen from another SSH session? Kill Attached Screen in Linux Save Screen (program) output to a file How do I increase the scrollback buffer in a running screen session? How to send control+c from a bash script? Terminal Multiplexer for Microsoft Windows - Installers for GNU Screen or tmux How do I get out of 'screen' without typing 'exit'? How to assign name for a screen? Kill detached screen session How to list running screen sessions?