To navigate directories in Linux, you primarily use the cd command, which stands for "change directory".
Here are the most common ways to use it:
1. Moving to a Specific Path
You can move to a specific folder by typing its name or path:
cd project— Moves you into the "project" folder (if it exists in your current location).cd /home/labex/project— Moves you directly to that specific absolute path.
2. The Home Shortcut (~)
The tilde symbol ~ is a shortcut for your home directory:
cd ~— Takes you home (/home/labex) from anywhere in the system.cd— Simply typingcdwith no arguments also takes you back to your home directory.
3. Moving Up One Level (..)
To go "backwards" or up to the parent directory:
cd ..— Moves you up one level. (For example, if you are in/home/labex/project, typingcd ..takes you to/home/labex).
4. Moving to the Last Directory (-)
cd -— This is like a "back" button; it takes you to the previous directory you were in.
Summary Checklist for Navigation:
| Command | Action |
|---|---|
pwd |
Check where you are. |
ls |
See what folders are available to enter. |
cd <name> |
Enter a folder. |
cd .. |
Go back up one level. |
Try this in your terminal:
- Type
cd ~to go home. - Type
pwdto confirm you are at/home/labex. - Type
cd projectto go back into your project folder. - Type
pwdagain!