cd — change directory
Command to change the working directory. Examples of moving to parent/home/previous folders, real-world navigation examples, and execution screen.
💬 "cd command"
- Concept: Short for Change Directory, it moves your current working directory to another location.
- Output structure: On success, nothing is output. If you try to move to a nonexistent path, an error message appears.
- Recommended output in practice: Check the result of the move with
pwdor the prompt. You can return to the immediately previous folder withcd -. - Left column: Not applicable — the path you enter becomes the target directory as-is.
- Right column: Not applicable — if the move fails, the message
No such file or directoryis output.
3 essential command combinations
cd /var/log— move to an absolute pathcd ..— move one level up to the parent foldercd -— return to the previous folder
There are also useful options to know.
- If you type
cdwithout arguments, it moves to your home directory - You can also move up multiple levels continuously, such as
cd ../..
💬 "Tell me one situation this command can solve"
Scenario: The process of entering the correct folder before deployment.
Step 1: Start from a parent directory
Move to the parent folder.
cd /var/www
Step 2: Enter the deployment folder
Enter the target folder.
cd app
Step 3: Verify
Check the current location and contents.
pwd && ls -al
Actual execution screen
This is an example of moving with cd and then checking the location with pwd.
!Current path confirmed with pwd after running cd
A production server
Source (HTML): https://games.aidebatehub.com/programs/linux/filesystem/cd.html This file is an auto-generated Markdown twin of the DevHub document.
AI Knowledge Hub
Visitor Comments