GNU/Linux >> Tutoriels Linux >  >> Linux

Comment utiliser la commande "screen" sous Linux

commande d'écran

La commande screen lance un terminal en arrière-plan qui peut être détaché puis reconnecté. Ceci est particulièrement utile lorsque vous vous connectez au système à distance. Vous pouvez démarrer un écran, lancer une commande, vous détacher de l'écran et vous déconnecter. Vous pouvez ensuite vous connecter plus tard et vous rattacher à l'écran et voir le programme en cours d'exécution.

Ci-dessous les options disponibles avec la commande screen :

# screen --help
Use: screen [-opts] [cmd [args]]
 or: screen -r [host.tty]

Options:
-4            Use IPv4.
-6            Use IPv6.
-a            Force all capabilities into each window's termcap.
-A -[r|R]     Adapt all windows to the new display width & height.
-c file       Read configuration file instead of '.screenrc'.
-d (-r)       Detach the elsewhere running screen (and reattach here).
-dmS name     Start as daemon: Screen session in detached mode.
-D (-r)       Detach and logout remote (and reattach here).
-D -RR        Do whatever is needed to get a screen session.
-e xy         Change command characters.
-f            Flow control on, -fn = off, -fa = auto.
-h lines      Set the size of the scrollback history buffer.
-i            Interrupt output sooner when flow control is on.
-l            Login mode on (update /var/run/utmp), -ln = off.
-list         or -ls. Do nothing, just list our SockDir.
-L            Turn on output logging.
-m            ignore $STY variable, do create a new screen session.
-O            Choose optimal output rather than exact vt100 emulation.
-p window     Preselect the named window if it exists.
-q            Quiet startup. Exits with non-zero return code if unsuccessful.
-r            Reattach to a detached screen process.
-R            Reattach if possible, otherwise start a new session.
-s shell      Shell to execute rather than $SHELL.
-S sockname   Name this session [pid].sockname instead of [pid].[tty].[host].
-t title      Set title. (window's name).
-T term       Use term as $TERM for windows, rather than "screen".
-U            Tell screen to use UTF-8 encoding.
-v            Print "Screen version 4.00.03 (FAU) 23-Oct-06".
-wipe         Do nothing, just clean up SockDir.
-x            Attach to a not detached screen. (Multi display mode).
-X            Execute [cmd] as a screen command in the specified session.

Démarrer une session d'écran

Pour démarrer une session d'écran, tapez la commande :

# screen

Vous pouvez exécuter n'importe quelle application normalement une fois que vous avez exécuté la commande screen. Lorsque vous exécutez l'écran, une commande lance un terminal en arrière-plan.

Se détacher de l'écran

Pour vous détacher de l'écran, appuyez successivement sur les touches suivantes. Vous recevrez un message sous la forme "[détaché] ” lorsque la session est détachée. Le terminal en arrière-plan se détache avec cela.

Ctrl+a+d
[detached]

Vous pouvez également utiliser le -d option si vous souhaitez détacher l'écran d'un autre terminal. ici, vous devez spécifier l'ID d'écran qui peut être obtenu à partir de screen -ls commande.

# screen -d [screen id]

Par exemple :

# screen -ls
There are screens on:
        25168.pts-0.node01       (Attached)
1 Socket in /var/run/screen/S-root.
# screen -d 25168.pts-0.node01
[25168.pts-0.node01 detached.]

Rattacher à l'écran

Pour rattacher à l'écran tapez la commande :

# screen -r

Liste des écrans en cours d'exécution

Pour lister les écrans avec leur statut (attaché/détaché) utilisez l'option -list of -ls.

# screen -ls
There are screens on:
        25045.pts-0.node01       (Detached)
        25168.pts-0.node02       (Detached)
2 Sockets in /var/run/screen/S-root.


Linux
  1. Comment utiliser la commande Linux grep

  2. Comment utiliser la commande history sous Linux

  3. Comment utiliser la commande Su sous Linux

  4. Comment utiliser la commande id sous Linux

  5. Comment utiliser la commande d'écran Linux

Comment utiliser la commande fd sur le système Linux

Comment utiliser la commande screen sous Linux

Comment utiliser la commande wget sous Linux ?

Comment utiliser la commande xargs sous Linux ?

Comment utiliser la commande RPM sous Linux

Comment utiliser la commande which sous Linux