Skip to content

Terminal Tips and Tricks

someone2639 edited this page Aug 9, 2022 · 1 revision

Want to make your terminal experience so much smoother? You came to the right place!

Lesson 1: Navigating the filesystem

ls
ls -a
ls -l

ls shows the basic contents of the folder

ls -a shows all files, including hidden files (those that start with a .)

ls -l lists the contents, showing the file's permissions, size, owners, creation date, and more

Try combining the flags and see what's different!

See it in action!


cd

cd changes directory. If you want to get to another folder from the terminal, this is how you'd do it. There are also shortcut directories to make this easier:

~ (/home/username)
. (current folder)
.. (one level up)
/mnt/c/ (your C:\ drive on WSL)

See it in action!


Lesson 2: Tab to auto-complete

Don't be stuck writing long filenames by hand! As long as you type enough of the name, you can press the Tab key on your keyboard, and the name will be completed for you! If it doesn't fill the name automatically, press Tab again, and it'll show a list of choices to autocomplete.

See it in action!


Lesson 3: Exploring your WSL files through Windows

Now you know how to navigate the filesystem through the terminal, but what about through the File Explorer you know and love? Well, there's two easy ways to go about that:

explorer.exe .

Type this into your WSL terminal, and Windows Explorer will open to the folder the terminal is pointing to.

But what if you want to open a WSL file in a text editor? That's the job for mapping WSL to a real drive letter! Instead of using the weird network prefix (which doesn't even work in all apps), you can just browse it as if it were any old USB drive. Unfortunately, I don't have a Windows installation handy to show a video, but this guide should explain it well enough.