Overview
GNU Screen est un outil puissant pour gérer les sessions de terminal, permettant de détacher (detach) les sessions pour les exécuter en arrière-plan et de s'y reconnecter (attach) plus tard. screen-attach désigne ce processus de reconnexion et est très utile pour gérer des tâches de longue durée ou lorsque la connexion réseau est instable.
Key Features
- Reconnect to detached sessions
- Multiple connections to running sessions
- Maintain work during network disconnections
- Manage multiple terminal sessions
Main Options
Main options related to the 'attach' functionality of the `screen` command.
Session Connection
Commande générée :
Essayez de combiner les commandes.
Description:
`screen-attach` Exécute la commande.
Essayez d'exécuter virtuellement les commandes avec l'IA en combinant les options ci-dessus.
Usage Examples
Various ways to connect to a screen session.
Reconnect to the most recently detached session
screen -r
If there is only one detached session, it reconnects to that session.
Reconnect using a specific session ID
screen -r 12345
Connects to a specific session using the session ID obtained from the `screen -ls` command.
Reconnect using a specific session name
screen -r my_session_name
Connects using the name specified with the `-S` option when creating the session.
Multi-attach to an already attached session
screen -x
Simultaneously connects to a session that is already attached from another terminal.
Force detach and reconnect a session connected elsewhere
screen -D -r
If the session is already connected, it disconnects the existing connection and connects to the current terminal.
Installation
GNU Screen is included by default in most Linux distributions, but if it's not present, you can install it using the following commands.
Debian/Ubuntu
sudo apt update && sudo apt install screen
CentOS/RHEL/Fedora
sudo yum install screen
Arch Linux
sudo pacman -S screen
Tips & Precautions
Tips and precautions for effectively managing screen sessions.
Check the list of running Screen sessions
screen -ls
You can view a list of all currently active or detached screen sessions to identify session IDs and names.
How to Detach a Session
Press the key combination `Ctrl+a d` within a session to detach the current session and return to the terminal.
- Key Combination: Ctrl+a d
- Description: Detaches the current screen session and returns to the terminal.
Managing Multiple Sessions
When using multiple screen sessions, assign a unique name to each session (`screen -S my_session`) for easy reconnection using `screen -r my_session`.
Terminating a Session
A session terminates completely when all programs within it are closed or the `exit` command is entered. To force termination, you can use the command `screen -X -S [sessionID] quit`.