The terminal is a conversation
You write a command, press Enter, and the terminal answers. It is not a menu. The answer is what matters: a path, a list of names, or the silence of an empty folder.
At the start, three commands cover almost everything you need to find your way. Each one answers a single question. If the question is wrong, the right command looks useless.
The line below already shows the place
Before you type, look at the prompt. It is the line that ends in $. The text before it says who you are and which folder the terminal is in right now.
aluno@desafio:~$aluno is the user. desafio is the machine name. ~ is a shortcut for your home folder. $ is the invitation: you can write the command.
The command goes before Enter. A space separates the command from what comes after it. Capital letters count. pwd exists. PWD does not.
Solve
You wrote PWD and the terminal answered command not found. What happened?
pwd says the folder in full
pwd prints the full path of the current folder. It does not list files. It does not change place. It only answers: where am I.
Solve
You just opened the terminal and want to know which folder you are in. Which command?
aluno@desafio:~$ pwd
/home/alunoThe line that starts with / is the answer. /home/aluno means: inside home, this user's folder. The tilde on the prompt is only a shortcut for that same place. The two texts talk about the same folder.
ls lists the names
ls shows what is inside the current folder. Each name is a file or another folder. The command does not go anywhere.
aluno@desafio:~$ ls
Documents Downloads reportsIf the folder is empty, ls writes no line and the prompt comes back. That is not an error. There was no name to show.
Figure it out
ls went straight back to the prompt, with no text. What does that mean?
cd changes folder
cd switches the current folder. The name after it has to exist. After the command, the prompt changes. pwd confirms the new path.
aluno@desafio:~$ cd reports
aluno@desafio:~/reports$ pwd
/home/aluno/reportsNotice the difference. ls reports would show what is inside without leaving the folder above. The next command would still be in /home/aluno. cd reports is what changes the place.
Solve
ls showed the reports folder. You want the next command to run inside it. What comes now?
The order that does not confuse
First confirm the folder with pwd. Then look at what is there with ls. Only then go somewhere else with cd. At the end, run pwd again. If the path changed, cd worked.
aluno@desafio:~$ pwd
/home/aluno
aluno@desafio:~$ ls
Documents Downloads reports
aluno@desafio:~$ cd reports
aluno@desafio:~/reports$ pwd
/home/aluno/reportsFigure it out
You ran cd /tmp. Which command confirms that the folder changed?
The next step is navigating folders: see the place, list, enter, and go back. When a command says it cannot run, the subject is already permissions.
Categories