Finding Your Way
In this simple example, we’ll use Bash to navigate to a local directory on our computer. We can use a few simple commands to navigate the file structure.
- pwd – aka “print working directory" - this will tell you the current directory you are in
- cd – aka “change directory" - this will allow you to change directories
- ls – this will list the contents of the current directory
Another important concept in Linux is mount points. Think of this as shortcuts to external devices. Since Bash on Windows doesn’t really know about your Windows OS, it thinks of it as an external system. You can access your local Windows drives under the /mnt “directory."
Using the above information, we can use these commands to navigate to the C:\Program Files directory. Type these as you go along.
- pwd – you will see we are currently in the /root directory
- cd .. – this will take us up a directory
- ls – you can see all of the Linux directories present. Notice the /mnt directory – we’ll find Windows under there!
- cd /mnt
- ls – we can see my computer has a c and f drive
- cd c – this takes us into the C: drive
- cd “Program Files" – this will take us into the Program Files directory. Note the use of quotes is necessary because of the space between words.
A few things to note – Linux and Unix operating systems are case sensitive. If I had typed “cd ‘program files’" in the last line, it would have errored out.
In addition, you can combine “cd" statements instead of navigating one folder at a time. For example, at the /root directory, I could have typed “cd ‘../mnt/c/Program Files’" to take me directly to the Program Files directory.
There’s a lot more to cover – you can write Bash scripts to carry out tasks in an automated fashion, use Vi or Nano to edit documents and install utilities using the Ubuntu Apt commands. Let me know if there are any specific things you’d like me to cover in the comments down below!