If you’re using the fantastic Ubuntu Bash terminal in Windows 10 which gives you a proper Ubuntu Linux terminal window and subsystem, you’re probably wanting to access files on your main drive.
To get to your C drive which has your files, you can just type:
I don’t know about you, but typing that is painful. By creating an alias in your
.bashrc file which is a configuration file for the Ubuntu terminal instance, you can create a shortcut to the C drive (and other mounted drives as well).
Go into your home directory by typing:
Then open up your
.bashrc file in the Nano text editor by typing:
Go all of the way to the bottom and add in an alias. I called mine
cdrive but you can call yours whatever you want:
alias cdrive='cd /mnt/c'
ctrl+x to exit the text editor. You’ll be asked if you want to save your changes, type
Y and hit enter. Lastly, we need to tell the current terminal window about our changes by typing:
Now test your alias by typing
cdrive (or whatever you called it). You should be taken to your main drive. That’s it.
Thanks mate, clear instructions to get me going!
Awesome thank you, I knew there had to be a better way.
Exactly what I was looking for. Most of my UNIX command line experience dates back 30 years.
Really handy. Thanks. Got my “c” “d” and “e” aliases saving me lots of keystrokes.
Thank you so much for this! So helpful and clear.
I had some issues getting it to correctly point to wsl, had to pass in ‘~’ as an argument instead of ‘–login’ and it is working. Thanks!
It should be noted that .bash_aliases is preferred over editing .bashrc, especially because there is a segment included in .bashrc specifically to check for and source the .bash_aliases file should it exist. This makes it actually really convenient to keep all of your personal aliases in one place 🙂