Make Windows User Profile Directory Default In WSL Terminal.

Make Windows User Profile Directory Default In WSL Terminal.

·

2 min read

Windows Subsystem for Linux, also known as WSL, is like the ultimate matchmaker that brings Windows and Linux together in perfect harmony.

For a typical ‘windows person’ that is already conversant with your CMD terminal, you may find your default WSL terminal home directory a little bit confusing.

The essence of this short article is to help you configure the home directory of your WSL terminal to appear like that of your CMD shell.

Home Directory: WSL vs CMD

In WSL, the home directory typically corresponds to the user’s Linux user profile. It is located within the WSL file system and follows the standard Linux file hierarchy.

For example, the home directory for the user “john-doe” in WSL will be :

john-doe@Work-PC1:~$

On the other hand, in CMD , the home directory usually refers to the user’s Windows user profile directory. It is specific to the Windows operating system and follows the Windows file hierarchy.

For example, the home directory for the same user “john-doe” in CMD will be:

C:\Users\john-doe>

Configure WSL Home Dir

To configure the home directory of your WSL terminal to appear like that of your CMD shell. We open the WSL shell terminal and do the following:

  • Mount the users Windows C drive path and append this path to the .bashrc file
john-doe@Work-PC1 echo "cd /mnt/c/Users/name_of_user" >> ~/.bashrc

replace the name_of_user part should with the actual name of the user's home directory.(john-d in our case ).

The .bashrc file is a script file that is executed whenever a new interactive terminal session is started in the Bash shell.

After running the above command, subsequently anytime you re-open the WSL terminal the user Windows user profile directory is made the default directory in the WSL terminal, just like in the CMD shell.

user-dev@Work-PC1:/mnt/c/Users/John-Doe$

My first post on Hashnode, thanks for reading : ).