On June 12, 2019, Microsoft released a stable version of "Windows subsystem for Linux". With this feature, you can launch a Linux terminal in windows, like our windows command prompt and you can able to use all the available Linux commands & programs in windows itself.

This feature is available only in 64-bit Windows operating systems and the version should be at least 1607 or can be greater than that.

Check Windows version:

Press the Windows button and search for "windows update settings" and select the option "windows update settings" in the search results.

when I am writing this article, My windows version is 1909. It should be at least 1607 or can be greater than that.

If your Windows version is less than that, then click on "Check for updates".

Enable Windows Subsystem for Linux:

Once you update your windows to the latest version, navigate to the windows search and search for the control panel.

  • In the control panel, click on programs and select "Turn Windows features ON or OFF" under "programs and features".
  • Now you will see a pop-up with a list of windows features, Find "windows subsystem for Linux" and enable it.
  • After that click on OK and wait for some time until the changes are applied. Once the changes are applied, you will see a dialogue box with "Restart now". Click on "Restart now".

Download Ubuntu:

After restarting your computer, press the windows button and search for "Microsoft store". In the Microsoft store, search for "UBUNTU" while I am writing this article, 18.04 is the stable version of ubuntu.

  • Click on "install". After completing the download, click on launch and the Linux terminal will be opened with a message "Installing this may take a few minutes...". It might take 10-20 minutes to complete the installation.
  • After completing the installation, you will be prompted to choose a new UNIX username and password.
  • After choosing the username and password, then we have successfully installed the Linux terminal in windows.

Upgrade the package lists & Packages in ubuntu :

Before running any programs, type the below two commands in the terminal.

sudo apt update
sudo apt upgrade

Please be patient because both of these commands may take more time to complete their work.

Install GNU C Compiler

After finishing the packages update, then drop the below command in the terminal to install the GNU C compiler (GCC)

sudo apt-get install gcc

Install GNU Debugger:

After finishing the execution of the above command,  then enter the below command to install GNU Debugger (GDB)

sudo apt-get install gdb

Now we are ready to compose our "hello world" program.

Enter the below command to open vim editor by creating a new file named "helloword.c".

vim helloworld.c

Now press 'i' to enter into insert mode and enter the below hello world program:

#include <stdio.h>
int main()
{
    printf("Hello, world!");
    return 0;
}

After completing the program, then press ESC +:wq and hit ENTER

Note: w - write  & q - quit

Compile the C program:

Now type the below command to compile the program.

gcc helloworld.c

Execute the C program:

Now type the below command to execute the program

./a.out

"Hello, world!!" message printed on the screen.

Finally, we have successfully enabled the Linux terminal in windows and installed the C compiler in Linux.