Terminal, files and paths
The terminal is not a screen reserved for experts. This is another way of ask the operating system to open a folder, launch a program or inspect a file.
The essential mental model
A command is always executed from a current folder. Two orders identical can therefore produce a different result if they are launched from two different folders.
mon-projet/
├── package.json
├── src/
│ └── index.js
└── public/
└── logo.png
- an absolute path starts from the root of the system;
- a relative path starts from the current folder;
.designates the current folder;..designates the parent folder.
Cue commands
pwd # afficher le dossier courant
ls # voir son contenu
cd src # entrer dans le dossier src
cd .. # revenir au dossier parent
mkdir exercices # créer un dossier
Before running a command copied from a tutorial, always check the current folder and understand the files it will modify.
A delete command or a command executed with elevated rights can have effects that are difficult to reverse. Never issue an order unless you don't know how to explain.
Quick challenge
Create a laboratoire folder, enter it, then manually create a file
notes.md. Then go back to the parent folder and explain the difference
between laboratoire/notes.md and an absolute path to this same file.