How do I change directories?

QuestionsQuestions8 SkillsProYour First Linux LabAug, 19 2025
0175

To change directories in a terminal, you use the cd (change directory) command followed by the path to the directory you want to navigate to. Here’s how to do it step by step:

Steps to Change Directories

  1. Open the Terminal: Launch your terminal application.

  2. Use the cd Command:

    • To change to a specific directory, type cd followed by the path to that directory.

Examples

  • Changing to an Absolute Path:
    If you want to change to a directory using its absolute path, you would type:

    cd /path/to/directory

    For example:

    cd /home/user/documents
  • Changing to a Relative Path:
    If you are currently in /home/user and want to go to the documents directory, you can simply type:

    cd documents
  • Moving Up to the Parent Directory:
    To go up one level to the parent directory, use:

    cd ..
  • Changing to Your Home Directory:
    To quickly return to your home directory, you can use:

    cd ~

    or just:

    cd
  • Going Back to the Previous Directory:
    To switch back to the last directory you were in, use:

    cd -

Summary

  • Use cd followed by the directory path to change directories.
  • You can use absolute paths, relative paths, and shortcuts to navigate efficiently.

If you have any specific scenarios or further questions about changing directories, feel free to ask!

0 Comments

no data
Be the first to share your comment!