Back to Blog

Understanding the Linux File System | Directory Structure, Paths & Navigation

Sandy LaneSandy Lane

Video: Understanding the Linux File System | Directory Structure, Paths & Navigation by Taught by Celeste AI - AI Coding Coach

Watch full page →

Understanding the Linux File System | Directory Structure, Paths & Navigation

Linux organizes all files and directories in a hierarchical tree starting from the root directory (/). This structure includes key system folders like /home for user files, /etc for configurations, and /usr for programs. Navigating efficiently involves understanding absolute and relative paths, as well as special shortcuts like ~, ., .., and -.

Code

# List contents of the current directory
ls

# Show your current directory (absolute path)
pwd

# Change directory to home using tilde shortcut
cd ~

# Move up one directory level (parent directory)
cd ..

# Change to a specific absolute path
cd /etc

# Change to a relative path (e.g., 'documents' inside current directory)
cd documents

# Return to the previous directory you were in
cd -

# Examples of paths:
# Absolute path: /home/username/documents
# Relative path: documents (if you are in /home/username)

Key Points

  • The root directory (/) is the starting point of the Linux filesystem hierarchy.
  • Absolute paths begin with / and specify a full location, while relative paths depend on your current directory.
  • Use pwd to display your current working directory.
  • Special shortcuts like ~ (home), . (current), .. (parent), and - (previous) speed up navigation.
  • Commands like ls and cd are fundamental for exploring and moving through directories.