DEV Community

Cover image for WSL ubuntu m windows terminal and ls_colors
Dennis kinuthia
Dennis kinuthia

Posted on


WSL ubuntu m windows terminal and ls_colors

Brief Intro

If you're reading this you're probably like me and develop on windows, it has served me right but I recently found out that you can't avoid Linux as a developer,
configuring a dual boot solution was the go-to solution for this for a while.
but that comes with some limitations, for one you can only use one at a time and that was not an option when I was developing a server that was almost complete on windows until I had to add caching and Redis is a Linux only solution.
My options were to clone the project into a Linux environment or find a way to run limited Linux which would let me run the server in windows and Redis on Linux then I discovered the windows subsystem for linux (WSL) which allows you to run Linux in windows and have access to the Windows file system and a parallel Linux file system , that was perfect for my needs

The first step is installing wsl
Run the simple command:

wsl --install

windows will do a bunch of stuff under the hood includind downloading a linux distro (latest ubuntu by default)
see for more info and custom install instructions

Configuring windows terminal with WSL2 and ubuntu

you'll need a terminal to use linux bt sadly window's default offerings are less than desirable, that's why they made windows terminal
download from windows store

Navigate to your terminal, click on the dropdown button next to the plus sign on the tab area to open the side panel

windows terminal dropdown button

if ubuntu peofile doesn't already exist
go to settings>scroll down on list of profiles , at the bottom
click on open json file

in the profiles

     "commandline": "wsl.exe ~ -d Ubuntu",
     "guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
     "hidden": false,
     "name": "Ubuntu",
     "source": "Windows.Terminal.Wsl",
     "startingDirectory": "~"
Enter fullscreen mode Exit fullscreen mode

save in your editor and exit

you can optionally add if you have fish shell, for it to load fish by default on startup

"commandline": "wsl.exe ~ -d Ubuntu fish",

you might notice the ls colors being a little unreadable in which case you might want to do the following:

open ~/.bashrc with your favorite code editor

i'll use vscode

code ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

Note :the first line should be all one line , it won't work if put in multiple lines


export LS_COLORS

Enter fullscreen mode Exit fullscreen mode

if you relaunch your terminal the changes will appear
for more info on this

Now you have linux running in your windows enviroment with access to the main machine's file system
happy coding

more references
basic wsl commands
Windows terminal configuration

How to add gcc and Betty linter for c/cpp development

Top comments (0)

An Animated Guide to Node.js Event Loop

>> Check out this classic DEV post <<