The terminal is already in some folder
There is no terminal floating in the air. Every command runs inside a folder, the current folder. pwd prints that place in full. The tilde on the prompt, ~, is only a shortcut for your home folder.
aluno@desafio:~$ pwd
/home/alunoIf the answer is /home/aluno, you are in the aluno user's folder, inside home. The map of the three starter commands is in commands for beginners. Here the subject is using the three together, until you reach the right folder.
Look at the names before you enter
ls lists what is in the current folder. Each name is a file or another folder. The command does not enter anywhere. It only shows.
aluno@desafio:~$ ls
Documents Downloads reportsIf the folder is empty, ls writes no line. That is not an error. There was no name to show.
Solve
You ran ls and the terminal went straight back to the prompt, with no text. What does that mean?
Entering uses the name ls showed
cd changes the current folder. The name after it needs to be one of the names ls just showed, or a path that exists. After cd, the prompt changes. pwd confirms.
aluno@desafio:~$ cd reports
aluno@desafio:~/reports$ pwd
/home/aluno/reports
aluno@desafio:~/reports$ ls
april.txt may.txtNotice the difference. ls reports would show april.txt and may.txt without leaving the folder above. The next command would still be in /home/aluno. cd reports is what changes the place. From there, an ls with no path lists what is inside.
Solve
ls showed the projects folder. You want the next command to run inside it. What comes now?
Go up one level, or go home
cd .. goes up one folder. The two dots are the folder above, not a name you created. cd with nothing after it goes back to your home folder, the place the tilde points to, even if you are several levels down.
aluno@desafio:~/reports$ cd ..
aluno@desafio:~$ pwd
/home/alunoSolve
You are in /home/aluno/Documents/photos and want to go back only to Documents, the folder right above. Which command?
Figure it out
Now you are in /tmp and you want your folder, the one the tilde points to. Which command?
The name has to exist
If you type a name that is not there, the terminal says it did not find it. The way out is to run ls again and copy the name as it appears. Capital letters count: Photos and photos are different folders.
If the name has a space, the terminal needs quotes. cd "my files" goes in. Without quotes, it looks for a folder called my and treats files as something else.
Solve
cd photos answered that the folder does not exist. What do you check first?
When the folder exists and the terminal still says Permission denied, the path was right. The subject becomes permissions.
Categories