The Linux file system may seem different from Windows or macOS, but it's straightforward once you understand the basics. This guide covers essential terminal commands for navigating directories, managing files, and understanding the file system structure.

How to Navigate the Linux File System

  1. Step 1: Open Terminal

    Most file system navigation and management tasks are done through the terminal. Open it by searching for "Terminal" in the application menu.

  2. Step 2: Check Your Current Directory

    To know your current directory, use the pwd command (print working directory).

    pwd
  3. Step 3: List Files and Directories

    Use the ls command to list files and directories in the current location.

    ls
  4. Step 4: Change Directory

    Move to a different directory using the cd command.

    cd /path/to/directory

    To return to your home directory:

    cd ~

    To move up one level in the directory tree:

    cd ..
  5. Step 5: Understand Absolute vs. Relative Paths

    An absolute path starts from the root directory (/), while a relative path is relative to your current location. For example:

    • Absolute path: /home/username/Documents
    • Relative path: Documents (assuming you are already in /home/username)
  6. Step 6: Create a Directory

    Make a new directory using the mkdir command.

    mkdir new_directory
  7. Step 7: Remove Files and Directories

    Delete a file with the rm command and a directory with the rmdir command.

    rm filename
    rmdir directoryname
  8. Step 8: Copy and Move Files

    Copy files or directories using cp and move them using mv.

    cp source destination
    mv source destination
  9. Step 9: Change File Permissions

    Use chmod to change file permissions.

    chmod permissions filename
  10. Step 10: View File Content

    Use cat to display the entire content of a file.

    cat filename
  11. Step 11: Edit Files

    Use text editors like nano, vim, or gedit to edit files.

    nano filename
  12. Step 12: Find Files

    Use find to search for files in the file system.

    find / -name filename
  13. Step 13: Use Wildcards

    Use wildcards like * and ? for matching multiple files or characters.

    ls *.txt  # List all files with a .txt extension