Click here to Skip to main content
14,454,989 members

Linux on Windows

Rate this:
5.00 (12 votes)
Please Sign up or sign in to vote.
5.00 (12 votes)
22 Feb 2020CPOL
How to use WSL, GUI on WSL and how to compile for Linux on Windows
This article is useful for you who want to compile for Linux without having to use Linux, either because you don't like its interface or because an IDE you use is not available on this system, or for another reason; this article is also useful for you who want to test Linux without having to install it.

Install and Configure Linux

First, you install Linux on Windows (by the Microsoft Store).1 I chose Debian.

Download Debian

It is very easy to configure Debian.

GUI

Run the commands below to enable the GUI:

sudo apt update
sudo apt upgrade
sudo apt-get install xrdp

And one of the commands below (the first for install the Xfce4 ad the second to install the LXDE):

sudo apt-get install xfce4
sudo apt-get install lxde

If you choose the Xfce you will have to select your keyboard layout on the screen below:

Configuring Xfce

Every time you want to use the GUI, you have to run the command below and then open the Remote Desktop and connect to the localhost:3390.

sudo /etc/init.d/xrdp start

Remote Desktop

To make this command permanent run the command below inside the ~ directory and go to the end.

sudo nano .bashrc

Now you add the lines below, press Ctrl + X, press Y and after press Enter and restart.

sudo /etc/init.d/xrdp start
clear

Modifying .bashrc

And so as not to have to enter your username and password every time, click on show options on the Remote Desktop screen and in user name write the user name of your distribution and check allow saving my credentials.

How to make the GUI automatic

After you click on connect the following window will appear:

How to make the GUI automatic (the second window)

In that window click on more options, use a different account, fill in the username and password fields with the username and password of the distribution you chose and click OK.

In case of error, run the command below, change port=3389 (probably is in line 8) to port=3390, press Ctrl + X, press Y and after press Enter and restart.

sudo nano /etc/xrdp/xrdp.ini

In case of error

To restart, run the command below:

sudo /etc/init.d/xrdp restart

Debian with Xfce working:

Debian working with Xfce

Debian with LXDE working:

Debian with LXDE working

Comopile C and C++ for Linux

First, you need to install the gcc and g++, for this, run the commands below:

sudo apt-get install gcc
sudo apt-get install g++

And to compile C on Linux to Linux:

gcc program.c -o program

Where program.c is the file name and program is the program name.

And C++:

g++ program.cpp -o program

Where program.cpp is the file name and program is the program name.

If you want to make this on Windows (Command Prompt), you add the prefix "distribution run" where distribution is the distribution name.

Example:

I want to compile the file ddd.cpp in Windows with Debian. I run:

debian run g++ ddd.cpp -o ddd

And to run the program on Debian:

./program

Where program is the program name.

And to run on Windows (Command Prompt):

debian run ./program

Where program is the program name.

Grades

1 It cannot be Ubuntu or openSUSE if you want to use the GUI.

History

  • 22nd January, 2020: Initial version
  • 18nd Febuary, 2020: Second version

Read My Other Articles

If you have any comments, please leave a note below.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

No Biography provided

Comments and Discussions

 
QuestionGreat article - xrdp doesn't launch Pin
alleyes21-Feb-20 4:38
professionalalleyes21-Feb-20 4:38 
AnswerRe: Great article - xrdp doesn't launch Pin
Tiago Cavalcante Trindade22-Feb-20 3:49
MemberTiago Cavalcante Trindade22-Feb-20 3:49 
AnswerRe: Great article - xrdp doesn't launch Pin
alleyes15hrs 3mins ago
professionalalleyes15hrs 3mins ago 
QuestionWeb Browser don't work on XFCE4? Pin
snoopy00121-Feb-20 3:04
Membersnoopy00121-Feb-20 3:04 
AnswerRe: Web Browser don't work on XFCE4? Pin
magemaster21-Feb-20 9:57
Membermagemaster21-Feb-20 9:57 
GeneralRe: Web Browser don't work on XFCE4? Pin
snoopy00121-Feb-20 14:03
Membersnoopy00121-Feb-20 14:03 
GeneralRe: Web Browser don't work on XFCE4? Pin
Tiago Cavalcante Trindade22-Feb-20 9:02
MemberTiago Cavalcante Trindade22-Feb-20 9:02 
AnswerRe: Web Browser don't work on XFCE4? Pin
Tiago Cavalcante Trindade22-Feb-20 9:03
MemberTiago Cavalcante Trindade22-Feb-20 9:03 
GeneralRe: Web Browser don't work on XFCE4? Pin
alleyes15hrs 2mins ago
professionalalleyes15hrs 2mins ago 
GeneralThis is working well for me Pin
Member 1276350111-Feb-20 10:14
MemberMember 1276350111-Feb-20 10:14 
GeneralRe: This is working well for me Pin
Tiago Cavalcante Trindade16-Feb-20 12:16
MemberTiago Cavalcante Trindade16-Feb-20 12:16 
GeneralRe: This is working well for me Pin
Member 1276350117-Feb-20 12:05
MemberMember 1276350117-Feb-20 12:05 
GeneralRe: This is working well for me Pin
Tiago Cavalcante Trindade17-Feb-20 13:57
MemberTiago Cavalcante Trindade17-Feb-20 13:57 
GeneralMy vote of 5 Pin
Member 1276350111-Feb-20 9:53
MemberMember 1276350111-Feb-20 9:53 
GeneralRe: My vote of 5 Pin
Tiago Cavalcante Trindade16-Feb-20 10:42
MemberTiago Cavalcante Trindade16-Feb-20 10:42 
GeneralMy vote of 5 Pin
gc4328-Jan-20 4:47
Membergc4328-Jan-20 4:47 
GeneralRe: My vote of 5 Pin
Tiago Cavalcante Trindade31-Jan-20 11:57
MemberTiago Cavalcante Trindade31-Jan-20 11:57 
QuestionDebian Install Pin
Member 1393261623-Jan-20 11:12
MemberMember 1393261623-Jan-20 11:12 
AnswerRe: Debian Install Pin
Tiago Cavalcante Trindade23-Jan-20 12:14
MemberTiago Cavalcante Trindade23-Jan-20 12:14 
GeneralRe: Debian Install Pin
tolsen6423-Jan-20 20:21
Membertolsen6423-Jan-20 20:21 
GeneralRe: Debian Install Pin
FenderBaba23-Jan-20 21:21
MemberFenderBaba23-Jan-20 21:21 
SuggestionRe: Debian Install Pin
JD Esterby31-Jan-20 9:03
MemberJD Esterby31-Jan-20 9:03 
GeneralRe: Debian Install Pin
Tiago Cavalcante Trindade3-Feb-20 7:43
MemberTiago Cavalcante Trindade3-Feb-20 7:43 
GeneralRe: Debian Install Pin
Member 1276350117-Feb-20 18:00
MemberMember 1276350117-Feb-20 18:00 
AnswerRe: Debian Install Pin
Member 1276350117-Feb-20 12:05
MemberMember 1276350117-Feb-20 12:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Tip/Trick
Posted 21 Jan 2020

Stats

27.3K views
318 downloads
24 bookmarked