How to run screen on a Linux host reporting “Cannot make directory ‘/var/run/screen’: Permission denied”?

I want to run screen on a remote host on which I do not have root/sudo privilege and screen is not installed.

I can compile or copy the screen program that can run on the host. However, it reports:

“Cannot make directory ‘/var/run/screen’: Permission denied”

As screen is not installed on the host, the directory var/run/screen/ does not exist.

How to run screen on a Linux host without requiring root privilege?

The directory /var/run/screen/ is the socket directory for screen.

Fortunately, screen reads a environment variable SCREENDIR to get an alternative socket directory.

So to work around it, you can create a directory, such as ~/.screen:

mkdir ~/.screen && chmod 700 ~/.screen

and export the SCREENDIR to point to that directory:

export SCREENDIR=$HOME/.screen

You can also put this line into you ~/.bashrc so that it will also take effect afterwards.

Answered by Eric Z Ma.

Eric Z Ma

Eric is a father and systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *