One of the most common things you'll need to do in the command prompt is navigate your file system. To do this, we'll utilize the cd
and dir
keywords. Start by opening up a command prompt using one of the methods mentioned here. You most likely see something similar to what's below, where UserName
is your user.
C:\Users\UserName>
Regardless of where in your file structure you are, if your system is like most, we can start with this command:
cd C:\
This will change your current directory to the C:\
drive. Notice how the screen now looks like this
C:\>
Next, run a dir
so we can see anything in the C:\
drive
dir
This will show you a list of files and folders with some information about them, similar to this:
There's lots of good info here, but for basic navigation, we just care about the right-most column. Notice how we have a Users
folder. That means we can run this
cd Users
Now if you run dir
again, you'll see all the files and folders in your C:\Users
directory. Now, we didn't find what we wanted here, so let's go back to the parent folder. Rather than type the path to it, we can use ..
to go up one folder like so
cd ..
Now we are back in C:\
. If you want to go up multiple folders at once, you can put a backslash and another set of periods like so: cd ..\..
, but we only needed one folder.
Now we want to look in that Program Files
folder. To avoid confusing the system, it's a good idea to put quotes around the directories, especially when there are spaces in the name. So this time, we'll use this command
C:\>cd "Program Files"
Now you are in C:\Program Files>
and a dir
command now will tell you anything that's in here.
So, say we get tired of wandering around to find the folder and looked up exactly where we were needing to go. Turns out it's C:\Windows\Logs
Rather than do a ..
to Windows
to Logs
, we can just put the full path like so:
cd "C:\Windows\Logs"
And that's the basics of navigating the command prompt. You can now move through all your folders so you can run your other commands in the proper places.