What are other uses for `cd`?

QuestionsQuestions8 SkillsProDec, 10 2025
060

That's a good question! While cd /home/labex/project is a very specific use, the cd command (which stands for change directory) is one of the most fundamental and frequently used commands in the Linux terminal for navigating the file system.

Here are some other common uses for cd:

  1. Navigating to a specific directory (absolute path):

    cd /usr/local/bin

    This takes you directly to the /usr/local/bin directory, regardless of where you currently are.

  2. Navigating to a subdirectory (relative path):

    cd myfolder

    If you are in /home/labex/project and run this, you will move into /home/labex/project/myfolder (if myfolder exists within project).

  3. Moving up one directory level:

    cd ..

    This command moves you up to the parent directory. If you are in /home/labex/project, cd .. would take you to /home/labex.

  4. Moving to your home directory:

    cd
    # or
    cd ~

    Both commands will take you directly to your user's home directory (e.g., /home/labex in this environment).

  5. Moving back to the previous directory:

    cd -

    This is super handy! It switches you back to the directory you were in just before your current one.

  6. Navigating to a relative path using . (current directory):

    cd ./documents

    While cd documents usually works fine, cd ./documents explicitly indicates you're looking for documents within the current directory. It's less common but sometimes used for clarity or in scripting.

The cd command is your primary tool for moving around the file system in the terminal. Mastering it makes navigating Linux much more efficient!

Do any of these examples spark more questions, or would you like to continue with the lab?

0 Comments

no data
Be the first to share your comment!