Detailed explanation of screen command usage in Linux

Detailed explanation of screen command usage in Linux

GUN Screen:

Official website: http://www.gnu.org/software/screen/

1. Introduction

Screen is a free software developed by the GNU project for command line terminal switching. Users can use this software to connect to multiple local or remote command line sessions at the same time and switch between them freely. GNU Screen can be thought of as a command-line interface version of a window manager. It provides a unified interface and corresponding functions for managing multiple sessions.

In the Screen environment, all sessions run independently and have their own number, input, output, and window buffer. Users can switch between different windows using shortcut keys and can freely redirect the input and output of each window.

2. Grammar

$> screen [-AmRvx -ls -wipe][-d <作業名稱>][-h <行數>][-r <作業名稱>][-s ][-S <作業名稱>]

-A Resize all windows to the size of the current terminal.
-d <job name> Take the specified screen job offline.
-h <number of lines> specifies the number of buffer lines for the window.
-m Forces the creation of a new screen job even if one is already in progress.
-r <job name> Restore the offline screen job.
-R Try to recover offline jobs first. If the offline job cannot be found, a new screen job is created.
-s specifies the shell to be executed when creating a new window.
-S <job name> specifies the name of the screen job.
-v Display version information.
-x Restore the previously offline screen job.
-ls or --list displays all current screen jobs.
-wipe checks all current screen jobs and deletes those that are no longer usable.

3. Common screen parameters

screen -S yourname -> create a new session called yourname
screen -ls -> List all current sessions
screen -r yourname -> Return to yourname session
screen -d yourname -> remotely detach a session
screen -d -r yourname -> End the current session and return to the yourname session

4. In Session, use ctrl+a (Ca)

Ca ? -> Show all key binding information
Ca c -> Create a new window running the shell and switch to it
Can -> Next, switch to the next window
Cap -> Previous, switch to the previous window
Ca 0..9 -> switch to window 0..9
Ctrl+a [Space] -> Switch from window 0 to window 9 in sequence
Ca Ca -> Switch between the two most recently used windows
Ca x -> Lock the current window and need to use the user password to unlock
Cad -> detach, temporarily leave the current session, throw the current screen session (which may contain multiple windows) to the background for execution, and return to the state before entering the screen. At this time, in the screen session, the process running in each window (whether foreground/background) continues to execute, and even logout will not affect it.
Ca z -> Put the current session into the background and use the fg command of the shell to go back.
Ca w -> Show a list of all windows
Cat -> time, displays the current time and system load
Ca k -> kill window, force close the current window
Ca [-> Enter copy mode. In copy mode, you can scroll back, search, and copy just like using vi
Cb Backward, PageUp
Cf Forward, PageDown
H (uppercase) High, move the cursor to the upper left corner
L Low, move the cursor to the lower left corner
0 Move to the beginning of the line
$ End of line
w forward one word, move forward in units of words
b backward one word, move backward one word
The first press of Space marks the starting point of the area, and the second press marks the end point.
Esc ends copy mode
Ca ] -> paste, paste the content just selected in copy mode

5. Common operations

Create a session (-m forced):

screen -dmS session_name
# session_name session name

Close the session:

screen -X -S [session # you want to kill] quit

View all sessions:

screen -ls

Enter the session:

screen -r session_name

Part of the article reference: http://man.linuxde.net/screen

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Detailed explanation of screen command in Linux system command
  • Detailed explanation of screen commands in Linux
  • Screen command and usage in Linux

<<:  Mysql slow query optimization method and optimization principle

>>:  A brief analysis of the use of watchEffect in Vue3

Recommend

Multiple ways to insert SVG into HTML pages

SVG (Scalable Vector Graphics) is an image format...

Example of Html shielding right-click menu and left-click typing function

Disable right-click menu <body oncontextmenu=s...

What are the drawbacks of deploying the database in a Docker container?

Preface Docker has been very popular in the past ...

How to install multiple mysql5.7.19 (tar.gz) files under Linux

For the beginner's first installation of MySQ...

How to determine if the Linux system is installed on VMware

How to determine whether the current Linux system...

JS uses clip-path to implement dynamic area clipping function

background Today, I was browsing CodePen and saw ...

How to set the page you are viewing to not allow Baidu to save its snapshot

Today, when I searched for a page on Baidu, becaus...

How to run postgreSQL with docker

1. Install Docker. Reference URL: Docker Getting ...

How to reduce memory usage and CPU usage of web pages

Some web pages may not look large but may be very...

CSS3 creates web animation to achieve bouncing ball effect

Basic preparation For this implementation, we nee...

Detailed steps to use Arthas in a Docker container

What can Arthas do for you? Arthas is Alibaba'...

Detailed steps for installing rockerChat in docker and setting up a chat room

Comprehensive Documentation github address https:...

Syntax alias problem based on delete in mysql

Table of contents MySQL delete syntax alias probl...