WSL: Screen not working

When trying to run screen on the Windows Subsystem for Linux upon typing screen I get an error message stating:

Cannot make directory '/var/run/screen': Permission denied

Typing man screen I do however get the manual for screen so it does appear to be installed.

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Reactions: 6
  • Comments: 22 (2 by maintainers)

Most upvoted comments

One work-around is to do a “mkdir ~/.screen ; chmod 700 ~/.screen” and then add this to one of your shell’s startup files: “export SCREENDIR=/home/USERNAME/.screen” (with the right USERNAME).

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

Quoting the workaround posted in the link

On a freshly booted server install: $ screen -ls Cannot make directory ‘/var/run/screen’: Permission denied

This can be fixed with: $ sudo /etc/init.d/screen-cleanup start

I believe this is because /etc/rcS.d/S70screen-cleanup is running via upstart much earlier than it expects to have run, and is failing to correctly clean up that directory.

i added sudo /etc/init.d/screen-cleanup start to ~/.bash_profile and that seemed to do the trick

I like WayneD’s solution since it doesn’t mess with the system’s /run directory or the weird permission problems that screen-cleanup fixes. here’s what I put in my .bashrc (a more generic solution that you can copy-pasta):

export SCREENDIR=$HOME/.screen [ -d $SCREENDIR ] || mkdir -p -m 700 $SCREENDIR

I applied permission to /run/screen folder but every restart requires this fix. So I change the SCREENDIR to home folder. To fix for all users at WSL run below command.

echo 'export SCREENDIR="$HOME/.screen"'

if you start screen outside of bash like command line or scheduled task run with environment variables.

C:\Users\ahmet>bash -c 'SCREENDIR=$HOME/.screen screen'

@benhillis by now I would disagree: #774 fixed issues that prevented screen to work at all. After those were fixed, the issue was closed but left the problem Cannot make directory '/var/run/screen': Permission denied unfixed. So it is still (running Windows 10.0.16299.214) required - after each start of e.g. Ubuntu - to run screen once as root to initialized /var/run/screen, only then can screen be used as a normal user.

Since this issue was created for this specific problem, I’d suggest to reopen it. Another option would be to reference an issue that deals with the underlying problem (I’m no expert on this but it’s discussed in #774 ) so people like me who find this issue know where to look for a solution (or its status).

Same Looks WSL file permission was damaged after I copy some files from windows dir directly.

I run screen with sudo then chmod 777 /run/screen/

Seems worked.

You have to run it once as root

That does not solve the problem. Upon typing sudo screen I get a message stating sudo: unable to resolve host LAPTOP-6NV4LA2A. That message disappears immediately, the terminal is cleared and a message stating [screen is terminating] appears. If I subsequently type screen I get the same messages.

Closing bash, restarting it and typing screen produces the initial behaviour described in the original post again.

pjacob yeah you need to upgrade to an insider build, otherwise screen is not yet supported.

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

That’s #2530