{"id":1174,"date":"2025-03-09T14:10:46","date_gmt":"2025-03-09T04:10:46","guid":{"rendered":"https:\/\/nickdu.com\/?p=1174"},"modified":"2025-03-09T14:15:56","modified_gmt":"2025-03-09T04:15:56","slug":"linux-screen-commands-and-shortcuts","status":"publish","type":"post","link":"https:\/\/nickdu.com\/?p=1174","title":{"rendered":"Linux Screen Commands and Shortcuts"},"content":{"rendered":"\n<p id=\"909c\">Screen is a very powerful tool to keep a process running in the background while retaining the ability to log out and log back in anytime to check on the output.<\/p>\n\n\n\n<p id=\"9240\">Annoyingly I keep forgetting the commands to use&nbsp;<code>screen<\/code>&nbsp;effectively so here\u2019s a quick reference guide of commands and shortcuts for myself and maybe others.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"a800\">Commands<\/h1>\n\n\n\n<p id=\"e985\">To start a screen session:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ screen -S &lt;command&gt;<\/pre>\n\n\n\n<p id=\"f8c8\">To list existing screen sessions:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ screen -ls<\/pre>\n\n\n\n<p id=\"830b\">To reconnect to a screen session:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ screen -r &lt;session_name><\/pre>\n\n\n\n<p id=\"e6c5\">To reconnect to a still attached screen session:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ screen -rd &lt;session_name&gt;<\/pre>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"2d4e\">Shortcuts<\/h1>\n\n\n\n<p id=\"676e\">To detach a screen session:&nbsp;<code>ctrl + a + d<\/code><\/p>\n\n\n\n<p id=\"7eab\">To open a new screen session while inside screen:&nbsp;<code>ctrl + a + c<\/code><\/p>\n\n\n\n<p id=\"1735\">To switch back to the previous screen session:&nbsp;<code>ctrl + a + p<\/code><\/p>\n\n\n\n<p id=\"871c\">To switch to the next screen session:&nbsp;<code>ctrl + a + n<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Use: screen &#91;-opts] &#91;cmd &#91;args]]\n or: screen -r &#91;host.tty]\n\nOptions:\n-4            Resolve hostnames only to IPv4 addresses.\n-6            Resolve hostnames only to IPv6 addresses.\n-a            Force all capabilities into each window's termcap.\n-A -&#91;r|R]     Adapt all windows to the new display width &amp; height.\n-c file       Read configuration file instead of '.screenrc'.\n-d (-r)       Detach the elsewhere running screen (and reattach here).\n-dmS name     Start as daemon: Screen session in detached mode.\n-D (-r)       Detach and logout remote (and reattach here).\n-D -RR        Do whatever is needed to get a screen session.\n-e xy         Change command characters.\n-f            Flow control on, -fn = off, -fa = auto.\n-h lines      Set the size of the scrollback history buffer.\n-i            Interrupt output sooner when flow control is on.\n-l            Login mode on (update \/var\/run\/utmp), -ln = off.\n-ls &#91;match]   or\n-list         Do nothing, just list our SockDir &#91;on possible matches].\n-L            Turn on output logging.\n-Logfile file Set logfile name.\n-m            ignore $STY variable, do create a new screen session.\n-O            Choose optimal output rather than exact vt100 emulation.\n-p window     Preselect the named window if it exists.\n-q            Quiet startup. Exits with non-zero return code if unsuccessful.\n-Q            Commands will send the response to the stdout of the querying process.\n-r &#91;session]  Reattach to a detached screen process.\n-R            Reattach if possible, otherwise start a new session.\n-s shell      Shell to execute rather than $SHELL.\n-S sockname   Name this session &lt;pid&gt;.sockname instead of &lt;pid&gt;.&lt;tty&gt;.&lt;host&gt;.\n-t title      Set title. (window's name).\n-T term       Use term as $TERM for windows, rather than \"screen\".\n-U            Tell screen to use UTF-8 encoding.\n-v            Print \"Screen version 4.09.00 (GNU) 30-Jan-22\".\n-wipe &#91;match] Do nothing, just clean up SockDir &#91;on possible matches].\n-x            Attach to a not detached screen. (Multi display mode).\n-X            Execute &lt;cmd&gt; as a screen command in the specified session.\n<\/code><\/pre>\n\n\n\n<p><strong>References:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/jianjye.medium.com\/how-to-use-linux-screen-commands-and-shortcuts-quick-guide-f1a2207d15d3\">https:\/\/jianjye.medium.com\/how-to-use-linux-screen-commands-and-shortcuts-quick-guide-f1a2207d15d3<\/a><\/li>\n<\/ul>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Screen is a very powerful tool to keep a process running in the background while retaining the ability to log out and log back in anytime to check on the output. Annoyingly I keep forgetting the commands to use&nbsp;screen&nbsp;effectively so here\u2019s a quick reference guide of commands and shortcuts for myself and maybe others. Commands &hellip; <a href=\"https:\/\/nickdu.com\/?p=1174\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Linux Screen Commands and Shortcuts&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1174","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/posts\/1174","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nickdu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1174"}],"version-history":[{"count":3,"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/posts\/1174\/revisions"}],"predecessor-version":[{"id":1177,"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/posts\/1174\/revisions\/1177"}],"wp:attachment":[{"href":"https:\/\/nickdu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1174"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nickdu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1174"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nickdu.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1174"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}