Level 3 · 3A Systems and the terminal · Lesson 1 of 3
The terminal from scratch
The terminal is a window where, instead of clicking, you type instructions. Servers (the computers that run websites and apps) almost never have a screen or a mouse: they are managed this way. That is why anyone who works in security needs to feel at home here.
The four commands to move around
pwd tells you which folder you are in. ls lists what is in that folder. cd changes folders (cd documents goes in, cd .. goes up one level). cat shows the contents of a file. With those four you can already explore any computer.
pwd
ls
cd misiones
cat palabra.txt- pwd shows where you are.
- ls lists what is there.
- cd misiones goes into the misiones folder.
- cat palabra.txt shows the contents of the file.
Paths: how you write an address
A full path starts with a slash: /var/www/sitio always takes you to the same place, wherever you are. A relative path (config/ajustes.txt) counts from the folder you are in. The dot . means "here" and two dots .. mean "the folder above".
Do not mix up find and grep: find searches for files by their name, and grep searches for text inside files. You will use grep in depth in the next lesson.
Going deeper
Everything is a file
In Linux, settings, logs and even devices are stored as files inside a tree of folders that starts at the root (/). The usual folders: /home (the users), /var/log (the logs), /etc (the settings) and /tmp (temporary files, where anyone can write).
Review questions
Which command shows you which folder you are in?
Answer: pwd. pwd prints the current folder. ls lists what it contains and cat reads a file.
You are in /home/ana and you want to go to /var/www/sitio, no matter where you are. What do you type?
Answer: cd /var/www/sitio. The leading slash makes the path start from the root, so it works from any folder.
What is find . -name "ajustes.txt" for?
Answer: To search for a file by its name starting from the current folder. find goes through folders looking for matches; the dot means "from here".