Akuma-real

鬼鬼の小窝

hello!
tg_channel

Screen Package: Powerful Multi-Session Terminal Management Tool for Linux

In the Linux system, there is a widely used open-source software package called Screen (GNU Screen), which can help us manage terminal sessions more efficiently. This article will introduce the installation, basic operations, and some common commands of Screen.

First, installing Screen on Debian/Ubuntu systems is very simple, just execute the following command:

sudo apt install screen

For Red Hat/CentOS systems, you can use the following command to install:

sudo yum install screen

After installation, please follow the steps below to create and reconnect to a screen session.

  1. Create a new window:
    It is recommended to use the screen -R session_name command to create a new window and reconnect to the session. This command will first attempt to restore a detached session, and if it does not exist, it will create a new session.

    Alternatively, you can also press Ctrl+a+c in the current screen session to create a new window.

  2. Switch windows:
    Use the Ctrl+a+n shortcut to jump to the next window.
    Use the Ctrl+a+p shortcut to jump to the previous window.
    You can also directly press the number keys (such as 1, 2, 3...) to switch to a specific numbered window.

  3. Detach and restore the working environment:
    Use the Ctrl+a+d key to detach the current session and preserve the working environment for reconnection.
    Use the screen -R session_name command to reconnect to the detached session.

In addition, Screen also provides advanced features such as window bars and scroll mode, which can further enhance the control over screen sessions.

One of the most commendable features of Screen is its support for session persistence, allowing you to restore the working environment even after disconnecting from an SSH connection. You just need to specify a name when creating a new session:

screen -S session_name

For example:

screen -S MySession

To log in from a local computer to a remote server with an existing Screen session named "MyServer", please execute the following command:

ssh user@your_server_ip -t screen -r MyServer

Using the above methods, you can make better use of the Screen package to manage multiple session terminals and greatly improve work efficiency.

When you no longer need a specific or all created Screen sessions, simply exit each window one by one to close them. After all windows are exited, you can use the Ctrl+a+\ key to completely stop and clean up the entire Screen process.

It is recommended to use the screen -R session_name method to create and reconnect to screen sessions for efficient and flexible terminal management!

This article is synchronized and updated to xLog by Mix Space
The original link is https://api.xn--i2r.cc/posts/Technology-Sharing/TS3


Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.