Disclaimer: TubeMint is fully funded by its readers, we recommend hightly rated affiliate products and services and when you buy them through our links, we get commission at no extra cost to you. Thanks for you support!

How to Make/Change default directory in Bash/WSL Windows 10

How to change default directory with WSL/BASH on every time you launch your WSL on Windows 10. How make your user directory default directory every time your launch your BASH or WSL like Ubuntu, Debian, Apline, Arch Linux, Fedore, Suse, and other Linux distro.

To make this permanent default directory whenever you launch your WSL terminal, you’ll have to edit your .bashrc file with your favorite editor like nano or vim.

I’ll be using Micro ‘a terminal based text editor’ more like nano but Micro is a little more feature rich.

Launch Your WSL Terminal

I have launched my Ubuntu WSL 2 and it opens in Ubuntu home/user directory, which your check by running this pwd command, this tells you the current directory you are in.

pwd

To Get into Windows Directory

To change into your Windows directory, you have to change many directories which is time consuming and nobody wants waste time like that.

To manually change the directory, you type the following commnad

cd /mnt/c/User/user_name

To Make it Default WSL BASH Directory

Run the following commands, type the following commands in your WSL terminal.

cd 

The above command will take you to /home/user_folder

Edit .bashrc

I’ll be using Micro text editor, you can use nano or vim

sudo micro .bashrc

Run the above command and enter your password and it should open your .bashrc file.

Type the following command to launch your BASH WSL terminal in your choice of directory.

cd /mnt/c/User/User_Name

Change /User_Name with your username; save the file and exit.

Okay, you are done. Just relaunch your WSL terminal.



Leave a Reply