How do I detach a screen session from a terminal?

Ctrl+a followed by d. Note the lower case. The [screen manpage] has a long list of these shortcuts under "DEFAULT KEY BINDINGS".


To list your sessions, run:

screen -list

You can run any command under screen command like:

screen myscript.sh

Then press Ctrl+a (release) and then d to detach the process/screen (so it'll continue to run).


To resume detached process, use:

screen -r

If you have multiple, then add the session number after that.


You can also re-attach to already Attached screen by screen -x. Useful to investigate why it's attached, share terminal with someone or to watch/check somebody what they're doing.


For more help, either run man screen or within the screen press Ctrl+a, release and then hit ? to see more shortcuts.

See also:

  • How to execute a command in screen and detach?

You'll probably see it listed like this in the screen man page:

^a - d

It's important the note the case of the letters as uppercase and lowercase will do different functions.


Some systems remove certain bindings by default. So it is best to look at the online keybinding page: Ctrl-a ?. You can also use the command prompt in screen: Ctrl-a :detach. Myself, I generally remove the key bindings for 'detach' and 'powerdetach', except on remote systems.