I accidently deleted /var/run/screen/S-root/25771.pts-0 and when I try to run screen again 
screen bash ...
it reports:
/var/run/screen/S-root/25771.pts-0: No such file or directory
How can I recover it?
Check to see if you have the environment variable STY set:
[user@machine ~] echo $STY
25771.pts-0
If the variable is set, then you are telling screen to reattach to an existing session. If that session doesn't exist, then you will see the error you are getting.
To solve this, just clear the environment variable by running:
export STY=
and try starting screen again.
This scenario may have occurred because you previously had a screen session running (which setup the STY environment variable for you) which has now closed. For example:
xterm
screen
# The following xterm will inherit the existing STY environment variable.
xterm &
# close the initial xterm, and in the new xterm run the following:
screen
The final call to screen will give you your error, because it still has the environment variable STY from the original (now-gone) screen session.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With