Screen
Sommaire
Introduction[modifier]
Screen est vraiment géniale, mais si on ne l'utilise pas tous les jours, alors on perd vite ses repères. Screen sert à garder une session ouverte avec pourquoi pas une application qui tourne dessus. Lorsqu'on quitte la fenêtre et qu'on y revient plus tard, notre appli tourne toujours et nous pouvons reprendre totalement la main dessus.
Je met en garde car, j'en ai vu plus d'un faire ça, mais screen n'est pas un équivalent de nohup !!!
Installation[modifier]
Comme dab :
apt-get install screen
Utilisation[modifier]
Voici donc les principales commandes que j'utilise (c-a = Ctrl+a) :
c-a c nouvelle fenêtre c-a k fermer une fenêtre c-a p précédente fenêtre c-a n fenêtre suivante
c-a " affiche toutes les fenêtres disponibles c-a [0-9] aller à la fenêtre 0-9
c-a S Diviser l'écran c-a <tabulation> passer à la fenêtre suivante c-a X Fermer la fenêtre divisée c-a q Fermer toutes les fenêtres divisées c-a M Monitorer une fenêtre
Muti-utilisateurs[modifier]
Methode 1[modifier]
Sur la première machine, faire un screen avec l'utilisateur toto :
screen
Puis depuis une deuxième machine, se connecter en ssh directement avec l'utilisateur toto puis faire :
screen -x
Maintenant les 2 personnes peuvent interréagir directement ensemble.<br / Il existe également des ACL pour screen.
Methode 2[modifier]
Using screen in multiuser mode requires screen to be as setuid root. If you know about the potential security implications you can enable it by issuing
chmod u+s `which screen` chmod 755 /var/run/screen
We need to configure screen to use multiuser mode and change privileges for the guest. Put the following commands into ~/.screenrc. You can also use them in a screen session after pressing CTRL-a :
multiuser on aclchg snoopy -x "?" #Revoke permission to execute any screen command aclchg snoopy +x "wall" #Allow writing simple messages in the terminal status line aclumask snoopy-wx #Default permissions to windows acladd snoopy #Enable user snoopy to access screen session
Start screen :
user@localhost $ screen
user@localhost $ screen -ls
There is a screen on:
11521.pts-4.hostname (Multi, attached)
1 Socket in /var/run/screen/S-user.
Now the guest can attach to the screen :
screen -r user/11521
ACL[modifier]
Pour autoriser toto a voir la session sans pour autant pouvoir agir :
aclchg toto -w "#?"
Par défaut, les permissions sont "rwx". Voici d'autres exemples très compréhensibles :
aclchg toto -wx "#?" aclchg toto +x "detatch,wall,colon"
La dernière commande n'autorise que certaines options à être exécutées. Wall permet de passer des messages sur tous les écrans connectés.
Configuration[modifier]
.screenrc[modifier]
Copiez ceci dans un fichier ".screenrc" dans votre home (~/.screenrc) :
| Config File : .screenrc |
# Screenrc configuration
# ~/.screenrc
# Disable Startup message
startup_message off
deflogin on
# Scrollback
defscrollback 10240
# Disable flash screen
vbell off
# Binding keys
bind ^k
bind ^\
bind \\ quit
bind K kill
bind I login on
bind O login off
bind } history
bindkey "^?" stuff "^H"
# An alternative hardstatus to display a bar at the bottom listing the
# windownames and highlighting the current windowname in blue. (This is only
# enabled if there is no hardstatus setting for your terminal)
hardstatus on
hardstatus alwayslastline
hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} Load: %l %{..Y} %m/%d %C%a "
# Vertical Split
split
split -v
focus bottom
split -v
|