On June 12, 2019, Microsoft released a stable version of the “Windows subsystem for Linux.” With this feature, you can launch a Linux terminal in Windows, like our Windows command prompt, and use all the available Linux commands and 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, 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, but it 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 have the latest version of Windows, go to Windows Search and look 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.” While I am writing this article, 18.04 is the stable version of Ubuntu in the Microsoft Store.

  • 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><br>int main()<br>{    <br>    printf("Hello, world!");<br>    return 0;<br>}

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.

Categorized in:

Tagged in: