수. 7월 23rd, 2025

Navigating directories is fundamental in Linux, and the cd (Change Directory) command is your compass. Let’s break it down step by step with practical examples.


🔍 What is the cd Command?

cd lets you move between directories in the terminal. Think of it as double-clicking folders in a GUI file manager, but faster and more powerful.

Basic Syntax:

cd [options] [directory_path]

🖼️ Visualizing Directory Structure

Before diving in, imagine this directory tree:

home/
├── user/
│   ├── Documents/
│   ├── Downloads/
│   └── Pictures/
└── shared/

🛠️ Practical cd Examples

1. Move to Home Directory

cd ~
# or simply:
cd

Home Directory Path

2. Navigate to a Subdirectory

cd Documents/Projects/

Relative Path Navigation

3. Use Absolute Paths

cd /home/user/Documents

Tip: Absolute paths start with /.

4. Go Back One Directory

cd ..

Parent Directory

5. Return to Previous Directory

cd -

Handy for toggling between two locations!


💡 Pro Tips

  • Tab Completion: Type cd Docu + Tab → autocompletes to Documents/.
  • Spaces in Paths? Use quotes or escape spaces:
    cd "New Folder"
    cd New\ Folder
  • Home Shortcut: ~ always points to your home directory.

❌ Common Mistakes

  1. Missing Spaces:
    Wrong: cd.. → Correct: cd ..
  2. Typos: Linux is case-sensitive! Downloadsdownloads.
  3. Nonexistent Paths: Verify paths with ls before navigating.

🎯 Key Takeaways

Command Action
cd Go home
cd folder Enter subfolder
cd .. Move up one level
cd - Return to last directory
cd /full/path Jump directly to any location

💻 Try This Exercise!

  1. Open your terminal
  2. Run:
    mkdir -p test/demo  # Create practice folders
    cd test
    cd demo
    cd ../..

    Watch how you navigate up two levels!


🔚 Conclusion

The cd command is your navigation powerhouse in Linux. Start with these basics, practice daily, and soon you’ll zip through directories like a pro! 🚀

> “In Linux, every journey begins with a single cd.”

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다