Moving Around: pwd, ls, cd — and Four Keys So You Barely Type
You have the right window open with a dollar sign waiting. Here is the one idea that makes everything after this make sense: the terminal is always standing inside exactly one folder. Every command you type happens there, unless you say otherwise.
In a file manager you can see which folder you are looking at. In a terminal you cannot see it, so you ask. That is the only real difference between the two, and it is why the first command is a question.
Where am I?
pwdIt answers with a path, something like /home/ali or /c/Users/Ali. Read a path from left to right as a route: each slash is a step further in. When you open a terminal you almost always start in your home folder, which is where your Documents and Downloads live.
What is in here?
lsThis is your eyes. Get into the habit of running it constantly — before you move, after you move, and any time you are not sure. Experienced people run ls dozens of times an hour and think nothing of it.
Take me somewhere else
cd DocumentsNothing prints when it works. That silence is the terminal being polite: no news means it did what you asked. Run pwd and you will see you have moved. Getting back out is two dots, which always mean "the folder above this one":
cd ..Two shortcuts worth knowing today
- The tilde ~ means your home folder. So cd ~/Documents works from anywhere, no matter where you currently are.
- A path starting with a slash is measured from the very top of the machine, not from where you are. That is the difference between "from here" and "from the root".
Four keys, so you barely type
This is the part that turns the terminal from a slower way of working into a faster one. None of it is a command — it is just how the shell behaves once you know it is there. If typing in a terminal still feels slow, it is because you are missing these.
- Tab — type the first few letters of a name and press Tab. The shell finishes it. Press it twice to see all the matches. Nobody types full paths by hand.
- Up arrow — brings back the command you ran before, one press each. Most of what you run is something you have already run.
- Ctrl+R then a few letters — searches everything you have ever typed. Faster than remembering.
- Ctrl+C — cancels whatever is running right now. When something hangs, this is the way out, not closing the window.
You can move around and look. But everything you have seen so far already existed. So how do you make something of your own?