Bash Wiki
Posts (Latest 30 updated) :
Read all
Contents:
  1. [Linux] Bash cd uso: Change directory in the filesystem
    1. Overview
    2. Usage
    3. Common Options
    4. Common Examples
    5. Tips

[Linux] Bash cd uso: Change directory in the filesystem

Overview

The cd command, short for “change directory,” is used in Bash to navigate between different directories in the filesystem. It allows users to move to a specified directory, making it easier to manage files and execute commands in the desired location.

Usage

The basic syntax of the cd command is as follows:

cd [options] [arguments]

Common Options

  • -: Switch to the previous directory.
  • ..: Move up one directory level.
  • ~: Move to the home directory of the current user.
  • -P: Use the physical directory structure instead of following symbolic links.

Common Examples

Here are some practical examples of using the cd command:

  1. Change to a specific directory:
    cd /path/to/directory
    
  2. Move up one directory level:
    cd ..
    
  3. Return to the previous directory:
    cd -
    
  4. Navigate to the home directory:
    cd ~
    
  5. Change to a directory using a relative path:
    cd Documents/Projects
    

Tips

  • Use cd - frequently to toggle between two directories you are working with.
  • To quickly return to your home directory, simply type cd without any arguments.
  • If you want to see the current directory you’re in, use the pwd command after changing directories.