DEV Community

Cover image for Using Rstudio with windows subsystem for linux(wsl)
nuh yurduseven
nuh yurduseven

Posted on • Edited on

Using Rstudio with windows subsystem for linux(wsl)

Hi, In this post, I gonna show you how to install Rstudio on wsl system and to reach over the browser. if you are using windows and dont want to use Rstudio client in windows-side, this method will work perfectly.

Install windows-subsystem for linux

  • Open the Microsoft store and search "wsl" or "ubuntu" In windows store, There are many windows subsystem for linux distributions such as Ubuntu, debian, suse, kali, alpine wsl etc. You can use one of these distributions.
  • Installation can be done using the instructions in the terminal.
  • Determine username and password for linux subsystem.
  • You can use windows terminal or any terminal emulator for windows.

Note: It can be used graphical linux application via wsl2. wsl1 is not supported that. But you must install X window manager to use graphical application on wsl2. You can use rstudio desktop on wsl2 with this way.

Install R and Rstudio-server

In this stage, you should install Rstudio-server to subsystem side and you can install R environment to linux side as well. This is absolutely great trick for those switching to windows from linux.
For ubuntu or debian:

$ sudo apt-get install r-base
## after the instalation of R environment
$ sudo apt-get install gdebi-core
$ wget https://download2.rstudio.org/server/bionic/amd64/rstudio-server-2021.09.2-382-amd64.deb
$ sudo gdebi rstudio-server-2021.09.2-382-amd64.deb
Enter fullscreen mode Exit fullscreen mode

After the installation, You can start rstudio server via

$ sudo rstudio-server start
Enter fullscreen mode Exit fullscreen mode

To reach in windows side with browser

R environment and Rstudio server are installed and server is activated. you can access Rstudio from browser in windows side. Rstudio is working on localhost server and it can be accessed via browser http://localhost:8787 address.
To access the server, you have to have a username and password has been determined before. You can use the username and password you used during the installation of the subsystem.

rstudio-server

Conclusion

Using this method is absolutely great for those switching to windows from linux. Linux is more simple and more useful but using windows os with linux subsystem is quite influential. This method is used for any environment such as using python environment and jupyter notebook together.

Top comments (0)