Home » Tutorials » How to Change Ubuntu’s Starting Directory in Windows Terminal (or WSL)

How to Change Ubuntu’s Starting Directory in Windows Terminal (or WSL)

In this article, I’ll show you have to set the starting directory for Ubuntu in Windows Terminal. This solution is not a Windows Terminal-specific solution. It is general solution that will also work for WSL or on a native Ubuntu setup.

Changing Ubuntu’s Starting Directory in Windows Terminal

By default, Windows Terminal (and WSL) launches the Ubuntu Bash shell in Window’s user directory. That’s not practical considering that you aren’t supposed to mix files from Windows and Linux.

default windows terminal ubuntu starting path

Anyway, the solution is simple and takes about a minute at most: just add a cd command to change the directory in the user’s bash configuration file (/home/<user>/.bashrc).

For example, say we want the Ubuntu shell to start in the user’s home directory.

Just add the following line to the end of /home/<user>/.bashrc

cd ~

Where ~ is a short hand for your user home directory.

If you’re too lazy to type, here’s the command that will make the change for you:-

echo 'cd ~' >> $HOME/.bashrc

Result

changed wsl ubuntu starting directory to user home

Credits

  1. The folder vector is created by RawPixel.

WSL/Windows Terminal Guides

Default Shell | Remove Ubuntu Startup Message | Starting Ubuntu Directory