Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Screen not working #1245

Closed
pjacob2 opened this issue Oct 21, 2016 · 22 comments
Closed

Screen not working #1245

pjacob2 opened this issue Oct 21, 2016 · 22 comments

Comments

@pjacob2
Copy link

pjacob2 commented Oct 21, 2016

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.

@fpqc
Copy link

fpqc commented Oct 21, 2016

You have to run it once as root

@pjacob2
Copy link
Author

pjacob2 commented Oct 21, 2016

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.

@benhillis
Copy link
Member

Could you "sudo rm /etc/hosts", restart bash.exe, and try again? Looks like that file needs to be regenerated.

@pjacob2
Copy link
Author

pjacob2 commented Oct 21, 2016

Unfortunately that doesn't seem to change the behaviour either.

@fpqc
Copy link

fpqc commented Oct 21, 2016

@pjacob2 Are you on the insider build or 14393. I don't think this worked yet on 14393.

@pjacob2
Copy link
Author

pjacob2 commented Oct 21, 2016

I am running Version 1607, OS Build 14393.321.

@fpqc
Copy link

fpqc commented Oct 21, 2016

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

@benhillis
Copy link
Member

This is a duplicate of #774

@bjoernmartin
Copy link

@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).

@E14
Copy link

E14 commented Feb 23, 2018

By the way, tmux works just fine.

@therealkenc
Copy link
Collaborator

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

That's #2530

@WayneD
Copy link

WayneD commented Apr 4, 2018

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).

@shaycraft
Copy link

I don't understand why this is closed, as this is still happening.

@therealkenc
Copy link
Collaborator

Because dupe #2530 is open.

@ta946
Copy link

ta946 commented May 26, 2018

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

@philiaagape
Copy link

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

@dustin0329
Copy link

I can't read .screenrc. Can you?

@jayagami
Copy link

jayagami commented Dec 30, 2018

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.

@phdye
Copy link

phdye commented Apr 6, 2020

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 should make that sticky: chmod 01777 /run/screen

@ahmetozer
Copy link

ahmetozer commented Apr 18, 2020

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'

@Sayeed096
Copy link

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'

Excellent solution I think. I add that command in my .bashrc file.

@brookst
Copy link

brookst commented May 5, 2022

Another method is to use the screen-cleanup service on boot. WSL supports executing commands on VM boot via the /etc/wsl.conf file, like so:

[boot]
command="service screen-cleanup start"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

17 participants