{"id":410,"date":"2021-03-26T15:44:55","date_gmt":"2021-03-26T18:44:55","guid":{"rendered":"http:\/\/xaxowareti.com.br\/?p=410"},"modified":"2021-03-26T15:44:58","modified_gmt":"2021-03-26T18:44:58","slug":"how-to-use-linux-screen","status":"publish","type":"post","link":"https:\/\/xaxowareti.com.br\/?p=410","title":{"rendered":"How To Use Linux Screen"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"introduction\">Introduction<\/h2>\n\n\n\n<p>Screen or GNU Screen is a terminal multiplexer. In other words, it means that you can start a screen session and then open any number of windows (virtual terminals) inside that session. Processes running in Screen will continue to run when their window is not visible even if you get disconnected.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"install-linux-gnu-screen\">Install Linux GNU Screen<\/h2>\n\n\n\n<p>The screen package is pre-installed on most Linux distros nowadays. You can check if it is installed on your system by typing:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>screen --version<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Screen version 4.06.02 (GNU) 23-Oct-17\n<\/code><\/pre>\n\n\n\n<p>If you don\u2019t have screen installed on your system, you can easily install it using the package manager of your distro.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"install-linux-screen-on-ubuntu-and-debian\">Install Linux Screen on Ubuntu and Debian<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo apt update<\/code><code>sudo apt install screen<\/code>CopyCopy<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"install-linux-screen-on-centos-and-fedora\">Install Linux Screen on CentOS and Fedora<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo yum install screen<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"starting-linux-screen\">Starting Linux Screen<\/h2>\n\n\n\n<p>To start a screen session, simply type&nbsp;<code>screen<\/code>&nbsp;in your console:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>screen<\/code><\/pre>\n\n\n\n<p>This will open a screen session, create a new window, and start a shell in that window.<\/p>\n\n\n\n<p>Now that you have opened a screen session, you can get a list of commands by typing:<\/p>\n\n\n\n<p><code>Ctrl+a<\/code>&nbsp;<code>?<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"starting-named-session\">Starting Named Session<\/h3>\n\n\n\n<p>Named sessions are useful when you run multiple screen sessions. To create a named session, run the screen command with the following arguments:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>screen -S session_name<\/code><\/pre>\n\n\n\n<p>It\u2019s always a good idea to choose a descriptive session name.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"working-with-linux-screen-windows\">Working with Linux Screen Windows<\/h2>\n\n\n\n<p>When you start a new screen session, it creates a single window with a shell in it.<\/p>\n\n\n\n<p>You can have multiple windows inside a Screen session.<\/p>\n\n\n\n<p>To create a new window with shell type&nbsp;<code>Ctrl+a<\/code>&nbsp;<code>c<\/code>, the first available number from the range&nbsp;<code>0...9<\/code>&nbsp;will be assigned to it.<\/p>\n\n\n\n<p>Below are some most common commands for managing Linux Screen Windows:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><code>Ctrl+a<\/code>&nbsp;<code>c<\/code>&nbsp;Create a new window (with shell)<\/li><li><code>Ctrl+a<\/code>&nbsp;<code>\"<\/code>&nbsp;List all window<\/li><li><code>Ctrl+a<\/code>&nbsp;<code>0<\/code>&nbsp;Switch to window 0 (by number )<\/li><li><code>Ctrl+a<\/code>&nbsp;<code>A<\/code>&nbsp;Rename the current window<\/li><li><code>Ctrl+a<\/code>&nbsp;<code>S<\/code>&nbsp;Split current region horizontally into two regions<\/li><li><code>Ctrl+a<\/code>&nbsp;<code>|<\/code>&nbsp;Split current region vertically into two regions<\/li><li><code>Ctrl+a<\/code>&nbsp;<code>tab<\/code>&nbsp;Switch the input focus to the next region<\/li><li><code>Ctrl+a<\/code>&nbsp;<code>Ctrl+a<\/code>&nbsp;Toggle between the current and previous region<\/li><li><code>Ctrl+a<\/code>&nbsp;<code>Q<\/code>&nbsp;Close all regions but the current one<\/li><li><code>Ctrl+a<\/code>&nbsp;<code>X<\/code>&nbsp;Close the current region<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"detach-from-linux-screen-session\">Detach from Linux Screen Session<\/h2>\n\n\n\n<p>You can detach from the screen session at any time by typing:<\/p>\n\n\n\n<p><code>Ctrl+a<\/code>&nbsp;<code>d<\/code><\/p>\n\n\n\n<p>The program running in the screen session will continue to run after you detach from the session.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"reattach-to-a-linux-screen\">Reattach to a Linux Screen<\/h2>\n\n\n\n<p>To resume your screen session use the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>screen -r<\/code><\/pre>\n\n\n\n<p>In case you have multiple screen sessions running on your machine, you will need to append the screen session ID after the&nbsp;<code>r<\/code>&nbsp;switch.<\/p>\n\n\n\n<p>To find the session ID list the current running screen sessions with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>screen -ls<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>There are screens on:\n    10835.pts-0.linuxize-desktop   (Detached)\n    10366.pts-0.linuxize-desktop   (Detached)\n2 Sockets in \/run\/screens\/S-linuxize.\n<\/code><\/pre>\n\n\n\n<p>If you want to restore screen 10835.pts-0, then type the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>screen -r 10835<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"customize-linux-screen\">Customize Linux Screen<\/h2>\n\n\n\n<p>When&nbsp;<code>screen<\/code>&nbsp;is started, it reads its configuration parameters from&nbsp;<code>\/etc\/screenrc<\/code>&nbsp;and&nbsp;<code>~\/.screenrc<\/code>&nbsp;if the file is present. We can modify the default Screen settings according to our preferences using the&nbsp;<code>.screenrc<\/code>&nbsp;file.<\/p>\n\n\n\n<p>Here is a sample&nbsp;<code>~\/.screenrc<\/code>&nbsp;configuration with customized status line and few additional options:~\/.screenrc<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Turn off the welcome message\nstartup_message off\n\n# Disable visual bell\nvbell off\n\n# Set scrollback buffer to 10000\ndefscrollback 10000\n\n# Customize the status line\nhardstatus alwayslastline\nhardstatus string '%{= kG}&#91; %{G}%H %{g}]&#91;%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}]&#91;%{B} %m-%d %{W}%c %{g}]'\n<\/code><\/pre>\n\n\n\n<p>Copy<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/linuxize.com\/post\/how-to-use-linux-screen\/gnu-screen-terminal_huda639eed55d78a91f0c2d2928023b132_295393_768x0_resize_q75_lanczos.jpg?ezimgfmt=rs:732x458\/rscb87\/ng:webp\/ngcb87\" alt=\"Gnu Screen Terminal\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"basic-linux-screen-usage\"><\/h2>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Screen or GNU Screen is a terminal multiplexer. In other words, it means that you can start a screen session and then open any number of windows (virtual terminals) inside that session. Processes running in Screen will continue to run when their window is not visible even if you get disconnected. Install Linux GNU [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-410","post","type-post","status-publish","format-standard","hentry","category-sem-categoria"],"_links":{"self":[{"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=\/wp\/v2\/posts\/410","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=410"}],"version-history":[{"count":1,"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=\/wp\/v2\/posts\/410\/revisions"}],"predecessor-version":[{"id":411,"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=\/wp\/v2\/posts\/410\/revisions\/411"}],"wp:attachment":[{"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=410"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=410"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=410"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}