Posey's Tips & Tricks
How To Navigate the File System in Windows 10's Bash Shell
Bash is fairly easy to install, but using it is another matter. Here are some commands to help IT pros dip their toes in Bash.
I have written quite a bit lately about the Bash shell that exists within Windows 10. Although it is relatively easy to install the Bash shell, using it can be something of a fish-out-of-water experience for even the most seasoned Windows administrators. While there is no way that I can possibly teach you all things Bash within a single column, I do want to take the opportunity to show you how to navigate the file system using the Bash shell.
Before I jump right in, I want to give you a bit of good news. For those who are well-versed in the Windows Command Prompt (or those who grew up using DOS like I did), the Bash experience probably won't be completely unfamiliar. Even though Bash uses a different set of commands than the Windows Command Prompt does, some of the Bash commands are at least somewhat similar to their Windows counterparts. In fact, I vaguely remember using a DOS shell may years ago that allowed DOS and UNIX commands to be used interchangeably.
So let's get started. Even though it doesn't have anything to do with navigating the file system, the first thing I want to show you is how to clear the screen. The Bash shell can get pretty cluttered, so it is helpful to know how to clear the clutter. In the Windows Command Prompt environment, the command used to clear the screen is CLS, which is short for Clear Screen. CLS doesn't work in the Bash environment, but you can clear the screen by typing CLEAR.
The command that is used in the Bash shell to navigate the file system is CD. This is the same command that is used in the Windows Command Prompt. Even though the command is the same, however, its usage differs a bit. Like the Windows Command Prompt, you can type CD\ to access the root directory. However, some of the other functionality works a little bit differently. Let me give you an example.
Let's suppose that I am in a Windows Command Prompt environment and am currently in the C:\Users\Brien folder, and I want to get to the C:\Windows\System32 folder. There are a number of different ways to accomplish this, but I typically use CD\ to get to the root directory. Depending on my mood, I might instead use the CD.. command. This causes Windows to drop down one level in the folder structure. If I were in C:\Users\Brien and I typed CD.., then I would be taken to C:\Users. Typing CD.. one more time would take me to C:\.
One at the root directory, I would typically type CD Windows to access the C:\Windows folder, and then type CD System32 to access the System32 folder. As an alternative, it is possible to type CD Windows\System32.
If I wanted to do all of this in a single step, I could simply type CD\Windows\System32. This would take me to the C:\Windows\System32 folder regardless of which folder I am currently in.
The Bash shell won't let you use commands such as CD.. or CD Windows. Instead, you will have to enter the CD command followed by a backslash and the name of the folder that you want to access. Therefore, you could get to the root directory by typing CD\. Likewise, you can get to C:\Windows\System32 by typing CD\Windows\System32. The important thing to remember is that when you use the CD command, you are always going to need to use the backslash with it.
In my experience, there are two main challenges associated with using the Bash shell. One challenge is figuring out which command to use, because some of the commands do tend to be different than those used in Windows. Windows, for instance, uses MD (Make Directory) to create a folder. Bash, on the other hand, uses MKDIR.
The other challenge is figuring out the command syntax. Fortunately, help is available. If you want to know how to use a command, type the MAN command (Instruction Manual), followed by the name of the command. For example, if you wanted to know how to use the MKDIR command, you could type MAN MKDIR.
One last thing that I want to mention is that in this column, I have typed most of the commands in all-caps. I did this as a way of separating commands from the rest of the text in the sentences. Bash commands do not have to be typed in uppercase letters.
Hopefully, the commands that I have shown you will get you to experiment with the Bash shell. I am planning to write about some other Bash commands in future installments.
Brien Posey is a 16-time Microsoft MVP with decades of IT experience. As a freelance writer, Posey has written thousands of articles and contributed to several dozen books on a wide variety of IT topics. Prior to going freelance, Posey was a CIO for a national chain of hospitals and health care facilities. He has also served as a network administrator for some of the country's largest insurance companies and for the Department of Defense at Fort Knox. In addition to his continued work in IT, Posey has spent the last several years actively training as a commercial scientist-astronaut candidate in preparation to fly on a mission to study polar mesospheric clouds from space. You can follow his spaceflight training on his Web site at.