Linux: Using screen and screen under su

Linux: Using screen and screen under su 



  If you need to run something and let is run after you close the session, you can use screen. Install the screen package and just run screen. You can de-attach from the screen shell, using the "CTRL+A" keyboard shortcut.

  To list the screen sessions, you can run "screen -ls" command:
debian:~# screen -ls
There are screens on:
        14573.pts-1.debian       (03/27/2019 06:59:01 PM)        (Attached)
        14546.pts-1.debian       (03/27/2019 06:58:55 PM)        (Detached)
To re-attach to a screen session you can run "screen -r {session name}":
 debian:~# screen -r 14573.pts-1.debian
In order to attach to the same screen session from different shells, you need to use the "-xr" arguments, enabling multi-display mode.
 debian:~# screen -xr 14573.pts-1.debian
When you need to run it under su, you'll face the issue below: 
debian:~# sudo su - silviu
silviu@debian:~$ screen
Cannot open your terminal '/dev/pts/5' - please check.
To override it, you can run the "script /dev/null" command. After that, you'll be able to open a screen shell:
silviu@debian:~$ script /dev/null
Script started, file is /dev/null
silviu@debian:~$ screen

Comments

Popular posts from this blog

JunOS - mount USB stick

SSH: Generating and using SSH keys

JunOS - loging on secondary node of a cluster and copying file between nodes