linux_wiki:screen

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
linux_wiki:screen [2014/11/23 20:51]
billdozor created
linux_wiki:screen [2019/05/25 23:50] (current)
Line 1: Line 1:
 ====== Screen ====== ====== Screen ======
 +
 +**General Information**
 +
 Screen is a "full-screen window manager that multiplexes a physical terminal between several processes". (screen man page) Screen is a "full-screen window manager that multiplexes a physical terminal between several processes". (screen man page)
  
 This allows you to have multiple virtual terminal "workspaces" within 1 actual terminal session. This allows you to have multiple virtual terminal "workspaces" within 1 actual terminal session.
  
-1Install if it is not already+**Checklist** 
-<code>+  * Distro(s): Any 
 +  * Package: screen 
 + 
 +---- 
 + 
 +===== Install and Start ===== 
 +<code bash>
 yum install screen yum install screen
 or or
Line 12: Line 21:
  
 2) Start a screen session 2) Start a screen session
-<code> +<code bash
-screen+screen -S MySession
 </code> </code>
  
Line 19: Line 28:
  
 3) To view a list of all key bindings: 3) To view a list of all key bindings:
-<code>+<code bash>
 Ctrl+a, then ? Ctrl+a, then ?
 </code> </code>
Line 26: Line 35:
 You only have to press "Ctrl+a" and then the key letter for the desired action. You only have to press "Ctrl+a" and then the key letter for the desired action.
 Press Space ore Enter to leave the help screen. Press Space ore Enter to leave the help screen.
 +
 +----
  
 ===== Some Examples ===== ===== Some Examples =====
  
-=== Creating and Moving Between Screens ===+==== Creating and Moving Between Screens ====
  
 Start top in one screen, create a new screen, and cycle between the two. Start top in one screen, create a new screen, and cycle between the two.
  
 Start top Start top
-<code>+<code bash>
 top top
 </code> </code>
  
 Create a new screen Create a new screen
-<code>+<code bash>
 Ctrl+a, then c Ctrl+a, then c
 </code> </code>
  
 You will be on the new screen session. Do something else to see the difference: You will be on the new screen session. Do something else to see the difference:
-<code>+<code bash>
 free -m free -m
 </code> </code>
  
 Now, you can cycle between the two screen sessions by doing this: Now, you can cycle between the two screen sessions by doing this:
-<code>+<code bash>
 Ctrl+a, then n Ctrl+a, then n
 </code> </code>
Line 55: Line 66:
 You will notice that top was never interrupted, it was running the entire time on its screen session. You will notice that top was never interrupted, it was running the entire time on its screen session.
  
-=== Detach and Reattach Screen === +---- 
 + 
 +==== Detach and Reattach Screen ==== 
  
 The real power of screen is detaching a session and connecting back to it later. The real power of screen is detaching a session and connecting back to it later.
  
-You can either intentionally detach or get a SSH/network interruption and reconnect to your still running screen session. Perfect for long running processes or scripts.+Detach scenarios: 
 +  * Intentionally detach screen  
 +  * Be working on a remote system and get a SSH/network interruption 
 + 
 +In either scenario, you can reconnect to your still running screen session without loosing any work. Perfect for long running processes or scripts.
  
 This can be demonstrated by executing a for loop that echos a number, sleeps for 1 second, and then keeps going. This can be demonstrated by executing a for loop that echos a number, sleeps for 1 second, and then keeps going.
  
 1) If it is not open still, start screen 1) If it is not open still, start screen
-<code> +<code bash
-screen+screen -s MySession
 </code> </code>
  
 2) Start a long for loop...this should take about 5 minutes to complete. 2) Start a long for loop...this should take about 5 minutes to complete.
-<code>+<code bash>
 for NUM in {1..300} for NUM in {1..300}
 do echo -e "Number is: ${NUM}" do echo -e "Number is: ${NUM}"
Line 78: Line 95:
  
 3) Detach from screen after it has started. 3) Detach from screen after it has started.
-<code>+<code bash>
 Ctrl+a, then d Ctrl+a, then d
 </code> </code>
  
 4) List screen processes for your user. 4) List screen processes for your user.
-<code>+<code bash>
 screen -ls screen -ls
 </code> </code>
  
 This will give you output similar to the following: This will give you output similar to the following:
-<code> +<code bash
-bill@dt-bill:~$ screen -ls+bill@dt-bill ~ $ screen -ls
 There is a screen on: There is a screen on:
- 6732.pts-1.dt-bill (11/23/2014 07:28:40 PM) (Detached)+ 19734.MySession (03/09/2015 11:13:38 PM) (Detached)
 1 Socket in /var/run/screen/S-bill. 1 Socket in /var/run/screen/S-bill.
  
-bill@dt-bill:~$ ps -ef | grep 6732 +ps -ef | grep 19734 
-bill      6732  2738  19:28 ?        00:00:00 SCREEN+bill     19734      23:13 ?        00:00:00 SCREEN -S MySession
 </code> </code>
  
 You can see that the number is indeed a process ID. You can see that the number is indeed a process ID.
  
-5) Reattach to the screen: +5) Reattach to the screen using the session name or process id
-<code> +<code bash
-screen -r 6732+screen -r MySession 
 +or 
 +screen -r 19734
 </code> </code>
  
-Note: You only have to specify the screen PID if you have multiple screen sessions detached and you are connecting to a specific one.+Note: You only have to specify the screen PID if you have multiple screen sessions detached and you are connecting to a specific one. (If only 1 screen session, you can just type "screen -r")
  
 You should find your still running for loop, chugging away. You should find your still running for loop, chugging away.
 +
 +----
 +
 +==== Rename Existing Session ==== 
 +
 +If you started a new screen session without specifying a name or want to rename a session:
 +
 +1) Attach to your session
 +<code bash>
 +screen -r MySession
 +</code>
 +
 +2) Command Key, then colon
 +<code bash>
 +Ctrl+A :
 +</code>
 +
 +3) Type sessionname MyNewName, then enter
 +<code bash>
 +:sessionname MyNewName
 +</code>
  • linux_wiki/screen.1416793908.txt.gz
  • Last modified: 2019/05/25 23:50
  • (external edit)