{"id":200801,"date":"2021-03-12T17:00:03","date_gmt":"2021-03-12T14:00:03","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/define-a-great-gnu-screen-profile-using-screenrc-cloudsavvy-it\/"},"modified":"2021-03-12T17:00:03","modified_gmt":"2021-03-12T14:00:03","slug":"define-a-great-gnu-screen-profile-using-screenrc-cloudsavvy-it","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/define-a-great-gnu-screen-profile-using-screenrc-cloudsavvy-it\/","title":{"rendered":"#Define a Great GNU screen Profile Using .screenrc \u2013 CloudSavvy IT"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a2576cba9c74\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a2576cba9c74\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/define-a-great-gnu-screen-profile-using-screenrc-cloudsavvy-it\/#What_Is_screen\" >What Is screen?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/define-a-great-gnu-screen-profile-using-screenrc-cloudsavvy-it\/#Installing_screen\" >Installing screen<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/define-a-great-gnu-screen-profile-using-screenrc-cloudsavvy-it\/#Defining_a_Great_screenrc_Configuration\" >Defining a Great .screenrc Configuration<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/define-a-great-gnu-screen-profile-using-screenrc-cloudsavvy-it\/#Wrapping_up\" >Wrapping up<\/a><\/li><\/ul><\/nav><\/div>\n<p><strong>&#8220;#Define a Great GNU screen Profile Using .screenrc \u2013 CloudSavvy IT&#8221;<\/strong><\/p>\n<div id=\"article-content-area\">\n<figure style=\"width: 700px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-10123 size-full\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/cf06fed4aafbdd88eae121341de9ab6d\/p\/uploads\/2021\/03\/aaf6585f.png\" alt=\"\" width=\"700\" height=\"350\" data-crediturl=\"https:\/\/www.shutterstock.com\/image-vector\/web-development-coding-cross-platform-website-1128653108\" data-credittext=\"Shutterstock\/Andrey Suslov\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><figcaption class=\"wp-caption-text\"><span class=\"imagecredit\"><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.shutterstock.com\/image-vector\/web-development-coding-cross-platform-website-1128653108\">Shutterstock\/Andrey Suslov<\/a><\/span><\/figcaption><\/figure>\n<p>screen, the Linux utility which allows you to start a \u2018screen\u2019 inside a terminal, is by default a little under-configured. Learn how to create a great screen profile which is loaded automatically each time you use screen.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"What_Is_screen\"><\/span>What Is <i>screen<\/i>?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Screen is a GNU utility (GNU is a large collection of open source software, and the bundling thereof into an operating system is commonly known as <i>Linux<\/i>) which allows you start one or more screens inside your terminal.<\/p>\n<p>You may ask why would I want to start a screen inside my terminal, and can you define <i>screen<\/i> better\/further? Sure. Imagine that you are using a remote server of SSH and suddenly your network connection breaks, right in the middle of the database migration or production backup, which was running inside your terminal window. It h<a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">app<\/a>ens regularly, and the problem is that any command which was executing when the connection broke is now terminated, irrespective of the state it was in.<\/p>\n<p>This clearly annoying situation is one you want to avoid at all costs. Not only may it leave the system or software package in an undefined state, but all your work done this far may be simply lost.<\/p>\n<p>Welcome to <code>screen<\/code>, the Linux utility which allows you to start a virtual terminal session (a \u2018<i>screen<\/i>\u2018) inside your terminal session, with the primary and great benefit that such a screen session will not be terminated whenever the network connection breaks down, or when you close the terminal session which started the <code>screen<\/code> session (the parent process). You can simply wait till your network connection comes back, or open another terminal if you\u2019re not connected via SSH and working on the local machine only, and simply reconnect to your screen session.<\/p>\n<p>Great? Let\u2019s quickly install <i>screen<\/i> then if you haven\u2019t already:<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Installing_screen\"><\/span>Installing <i>screen<\/i><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>To install <i>screen<\/i> on your Debian\/Apt based Linux distribution (Like Ubuntu and Mint), execute the following command in your terminal:<\/p>\n<p><code>sudo apt install screen<\/code><\/p>\n<p>To install <i>screen<\/i> on your RedHat\/Yum based Linux distribution (Like RHEL, Centos and Fedora), execute the following command in your terminal:<\/p>\n<p><code>sudo yum install screen<\/code><\/p>\n<p>Now that screen is installed, you can start using it im<a href=\"https:\/\/buradabiliyorum.com\/en\/category\/social-mediaa\/\" data-internallinksmanager029f6b8e52c=\"1\" title=\"Social Media\" target=\"_blank\" rel=\"noopener\">media<\/a>tely. Simply execute <code>screen<\/code> at the command line and you\u2019re in. You may have to press enter or space to get through the <code>screen<\/code> splash screen.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-10018\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/6f396aaf96cc4ee5aa248e7adb46234d\/p\/uploads\/2021\/03\/4d91bbee.png\" alt=\"The Linux GNU Screen splash screen\" width=\"1118\" height=\"556\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>You will see a new command prompt. Press the key sequence <code>CTRL+a<\/code> &gt; <code>CTRL+d<\/code> to return to the command prompt of the parent shell session. Then, you can execute <code>screen -ls<\/code> to see a list of active screen sessions. Typing the command (in the parent shell you are in now if you followed the text identically), <code>screen -d -r<\/code> will bring you back into the <code>screen<\/code> session, provided that there is only one screen session active (you can start many).<\/p>\n<p>If there is more then one screen session running on your system (and owned by you), you can type <code>screen -d -r NAME<\/code> where <code>NAME<\/code> is the name of a screen as listed by <code>screen -ls<\/code>, for example <code>367434.pts-1.roel1<\/code>, though just specifying any part from either before or after the dot (like <code>367<\/code> or <code>pts<\/code>), which still uniquely identifies a particular screen session, is sufficient also.<\/p>\n<p>Let\u2019s see how we can now define a great screen profile, based on an excerpt from <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/github.com\/Percona-QA\/percona-qa\/blob\/master\/setup_server.sh\">setup_server.sh<\/a>, located in the Percona-QA GitHub repository (GPLv2 Licensed), a script created for setting up a server for quality assurance testing. I do not recommend you run this script as it is outdated, used as a reference only, and usually run manually step by step. The only section we will be using is the <code>.screenrc<\/code> code, reproduced below.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Defining_a_Great_screenrc_Configuration\"><\/span>Defining a Great .screenrc Configuration<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The <code>.screenrc<\/code> file is a hidden configuration file in your home directory. To edit it (it will likely not exist yet, especially if you just installed <code>screen<\/code>, simply use your favorite text editor and open the file <code>~\/.screenrc<\/code>. If you are experienced with Vim you can simply type at your terminal prompt <code>vi ~\/.screenrc<\/code>. If you would like to learn more about Vi\/Vim, consider reading our article Define a Great Vim Profile Using .vimrc.<\/p>\n<p>Once you have opened <code>~\/.screenrc<\/code>, simply add the following block of text:<\/p>\n<pre># <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/general\/\" data-internallinksmanager029f6b8e52c=\"3\" title=\"General\" target=\"_blank\" rel=\"noopener\">General<\/a> settings&#13;\nvbell on&#13;\nvbell_msg '!Bell!'&#13;\nautodetach on&#13;\nstartup_message off&#13;\ndefscrollback 10000&#13;\n&#13;\n# Termcapinfo for xterm&#13;\ntermcapinfo xterm* Z0=E[?3h:Z1=E[?3l:is=E[rE[mE[2JE[HE[?7hE[?1;4;6l   # Do not resize window&#13;\ntermcapinfo xterm* OL=1000                                                    # Increase output buffer for speed&#13;\n&#13;\n# Remove various keyboard bindings&#13;\nbind x    # Do not lock screen&#13;\nbind ^x   # Idem&#13;\nbind h    # Do not write out copy of screen to disk&#13;\nbind ^h   # Idem&#13;\nbind ^   # Do not kill all windows\/exit screen&#13;\nbind .    # Disable dumptermcap&#13;\n&#13;\n# Add keyboard bindings&#13;\nbind } history&#13;\nbind k kill&#13;\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-10019\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/c0ae7085bbba9849af12df06b41d6e99\/p\/uploads\/2021\/03\/b76675b0.png\" alt=\"Our .screenrc template\" width=\"936\" height=\"374\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>If you do not want to use a text editor, or want to somehow script the installation of this <code>.screenrc<\/code> file into many systems, you could use the following code instead, which will \u2013 whenever pasted, or executed from another script, create the file <code>~\/.screenrc<\/code> for the user who is executing the script. Let\u2019s call our script <code>make_screenrc.sh<\/code> or similar.<\/p>\n<pre>#!\/bin\/bash&#13;\n# Create screen script ~\/.screenrc&#13;\ntouch ~\/.screenrc&#13;\nif [ -z \"$(cat ~\/.screenrc|grep 'termcapinfo xterm')\" ]; then cat &lt;&lt; EOF &gt; ~\/.screenrc&#13;\n# General settings&#13;\nvbell on&#13;\nvbell_msg '!Bell!'&#13;\nautodetach on&#13;\nstartup_message off&#13;\ndefscrollback 10000&#13;\n&#13;\n# Termcapinfo for xterm&#13;\ntermcapinfo xterm* Z0=E[?3h:Z1=E[?3l:is=E[rE[mE[2JE[HE[?7hE[?1;4;6l   # Do not resize window&#13;\ntermcapinfo xterm* OL=1000                                                    # Increase output buffer for speed&#13;\n&#13;\n# Remove various keyboard bindings&#13;\nbind x    # Do not lock screen&#13;\nbind ^x   # Idem&#13;\nbind h    # Do not write out copy of screen to disk&#13;\nbind ^h   # Idem&#13;\nbind ^   # Do not kill all windows\/exit screen&#13;\nbind .    # Disable dumptermcap&#13;\n&#13;\n# Add keyboard bindings&#13;\nbind } history&#13;\nbind k kill&#13;\nEOF&#13;\nfi&#13;\n<\/pre>\n<p>The script presets a number of settings, and most of the ones here are quite self-explanatory. For example, <code>startup_message off<\/code> simply turns off the Splash screen we saw earlier. <code>defscrollback 10000<\/code> defines our scrollback to 10000 lines (you can access scrollback\/edit mode by pressing the key sequence <code>CTRL+a<\/code> &gt; <code>CTRL+ESC<\/code> and you can exit this mode by pressing ESC once or twice).<\/p>\n<p>We also turn on a virtual bell (as we cannot hear the speaker of a remote server beeping) by using the <code>vbell on<\/code> and <code>vbell_msg '!Bell!'<\/code> commands which set the virtual bell message to <code>'!Bell!'<\/code>. I have found however that the virtual bell often does not work.<\/p>\n<p>Next, we set some specific <code>termcapinfo<\/code> codes to enlarge out output buffer and adjust window resizing. We also remove various potentially annoying key bindings and add a few handy keyboard settings.<\/p>\n<p>All we have to do to activate this new <code>.screenrc<\/code> configuration is to open a new <code>screen<\/code> session. We will now benefit from the newly defined settings.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Wrapping_up\"><\/span>Wrapping up<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Defining a great default <code>.screenrc<\/code> file helps when you use <code>screen<\/code> a lot. Turning off the splash screen, increasing the scrollback, and improving the output buffer for speed are just a few of the things we did in our <code>.screenrc<\/code> template. <strong>Enjoy using screen and the .screenrc template!<\/strong>\n<\/div>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.cloudsavvyit.com\/10017\/define-a-great-gnu-screen-profile-using-screenrc\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#Define a Great GNU screen Profile Using .screenrc \u2013 CloudSavvy IT&#8221; Shutterstock\/Andrey Suslov screen, the Linux utility which allows you to start a \u2018screen\u2019 inside a terminal, is by default a little under-configured. Learn how to create a great screen profile which is loaded automatically each time you use screen. What Is screen? Screen is&#8230;<\/p>\n","protected":false},"author":1,"featured_media":200802,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/03\/aaf6585f.png","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-200801","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/200801","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=200801"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/200801\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/200802"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=200801"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=200801"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=200801"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}