unix command screen

Bismillah


https://www.rackaid.com/blog/linux-screen-tutorial-and-how-to/

which screen

---
start screen?
screen

--
control command

ctrl+a -> send commands to screen not shell
---
.screenrc #reconfigure these keys

Command: “Ctrl-a” “c”.

To create a new window, you just use “Ctrl-a” “c”.
--
Command: “Ctrl-a” “n”

Screen allows you to move forward and back. In the example above, you could use “Ctrl-a “n” to get back to top. This command switches you to the next window.
---
“Ctrl-a” “p” for the previous window.
--
Detaching From Screen
Command: “Ctrl-a” “d”

Detaching is the most powerful part of screen.  Screen allows you to detach from a window and reattach later.

If your network connection fails, screen will automatically detach your session!
You can detach from the window using “Ctrl-a” “d”.
-
This is great when you are using rsync for server migration
--
Reattach to Screen
If your connection drops or you have detached from a screen, you can re-attach by just running:

1
[jeffh@office ~]$ screen -r
---
However, if you have multiple screens you may get this:

1
2
3
4
5
[jeffh@office ~]$ screen -r
There are several suitable screens on:
31917.pts-5.office      (Detached)
31844.pts-0.office      (Detached)
Type "screen [-d] -r [pid.]tty.host" to resume one of them.
If you get this, just specify the screen you want.

1
[jeffh@office ~]$ screen -r  31844.pts-0.office
---
Logging Your Screen Output
As a consultant, I find it important to keep track of what I do to someone’s server. Fortunately, screen makes this easy.

Using “Ctrl-a” “H”, creates a running log of the session.

Screen will keep appending data to the file through multiple sessions. Using the log function is very useful for capturing what you have done, especially if you are making a lot of changes. If something goes awry, you can look back through your logs.
--
Getting Alerts
Screen can monitor a window for activity or inactivity. This is great if you are downloading large files, compiling, or waiting for output.

If you are waiting for output from a long running program, you can use “Ctrl-a” “M” to look for activity. Screen will then flash an alert at the bottom of the page when output is registered on that screen.
---
If you are downloading a large file or compiling a program, you can be notified when there is no more output. This is a great signal to when that job is done. To monitor for silence or no output use “Ctrl-A” “_”.
--
Locking Your Screen Session
If you need to step away from your computer for a minute, you can lock your screen session using “Ctrl-a” “x”.  This will require a password to access the session again.

1
2
Screen used by root <jeffh>.
Password:
Stopping Scree
---
Stopping Screen
When you are done with your work, I recommend you stop the session instead of saving it for later.  To stop screen you can usually just type exit from your shell. This will close that screen window.  You have to close all screen windows to terminate the session.

You should get a message about screen being terminated once you close all windows.

1
[screen is terminating]
Alternatively, you can use “Ctrl-a” “k”.  You should get a message if you want to kill the screen.

No comments:

Post a Comment