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

How to Install Xrdp Server (Remote Desktop) on Ubuntu 20.04

Xrdp is an open source implementation of Microsof...

This article will show you the basics of JavaScript: deep copy and shallow copy

Table of contents Shallow copy Deep Copy Replenis...

Use of align-content in flex layout line break space

1. The effect diagram implemented in this article...

How to use Maxwell to synchronize MySQL data in real time

Table of contents About Maxwell Configuration and...

TABLE tags (TAGS) detailed introduction

Basic syntax of the table <table>...</tab...

View the port number occupied by the process in Linux

For Linux system administrators, it is crucial to...

CentOS7 upgrade kernel kernel5.0 version

Upgrade process: Original system: CentOS7.3 [root...

Detailed tutorial on installing and using Kong API Gateway with Docker

1 Introduction Kong is not a simple product. The ...

How to fix some content in a fixed position when scrolling HTML page

This article mainly introduces how some content i...

A brief analysis of how to use border and display attributes in CSS

Introduction to border properties border property...

How to achieve centered layout in CSS layout

1. Set the parent container to a table and the ch...

Detailed explanation of the misunderstanding between MySQL and Oracle

Table of contents Essential Difference Database s...