How to View Directory Structure in Bash: Navigating the AI-For-Beginners Repository

You can view directory structure in Bash using commands like tree, ls -R, and find to inspect the hierarchical layout of repositories such as microsoft/AI-For-Beginners, which organizes its curriculum into numbered lesson folders, configuration files, and supporting assets.

The microsoft/AI-For-Beginners repository organizes a comprehensive AI curriculum using a nested directory structure that includes Jupyter notebooks, Python scripts, and a Vue-based quiz application. Learning how to view directory structure in Bash efficiently helps you navigate this educational codebase, locate specific lessons in the lessons/ folder, and understand the relationship between configuration files like environment.yml and the documentation entry point index.html.

Essential Bash Commands for Directory Navigation

Mastering these core commands allows you to inspect the AI-For-Beginners repository layout without leaving the terminal.

List Contents with ls

The ls command provides the fastest way to view folder contents.

  • ls -l – Displays a long-format listing showing permissions, owner, size, and timestamps for the current directory.
  • ls -R – Recursively lists every file and subdirectory, expanding the entire tree in a linear format.

Use ls -l when you need a quick check of top-level items like README.md or environment.yml. Use ls -R | less when you need a full recursive view but want to scroll through it gradually.

Visualize Hierarchy with tree

The tree command generates a hierarchical, indented diagram that is significantly more readable than linear lists.

Install it first if missing:


# Ubuntu/Debian

sudo apt-get install tree

# macOS

brew install tree

Then run:

tree -L 3

This shows three levels deep, perfect for revealing the structure of lessons/ without overwhelming detail. For a focused view of just the curriculum organization, use tree -d -L 2 lessons/ to display only directories.

Filter by Type with find

The find command offers precise control over what you display.

To view only directories up to a specific depth:

find . -type d -maxdepth 2

This command helps you get a high-level map of top-level groups like lessons/, etc/, and examples/ without seeing individual files.

Analyze Disk Usage with du

To identify which folders consume the most storage:

du -h --max-depth=1 | sort -hr

This displays the size of each top-level folder sorted largest-first, helping you spot large data directories like data/mnist.pkl.gz before exploring them.

Understanding the repository layout helps you apply these commands effectively. The microsoft/AI-For-Beginners codebase follows this organization:

  • Root – Contains high-level documentation (README.md, AGENTS.md), Conda environment specifications (environment.yml), and the Docsify site entry point (index.html).
  • lessons/ – The core curriculum split into numbered sub-folders (e.g., 0-course-setup/, 1-Intro/, 2-Symbolic/). Each sub-folder holds Jupyter notebooks (*.ipynb) and supporting Python scripts.
  • etc/ – Houses auxiliary assets including the Vue.js quiz application (quiz-app/), translation utilities, and Mind-map assets.
  • examples/ – Contains small, runnable Python scripts such as 01-hello-ai-world.py and 04-text-sentiment.py.
  • binder/ – Configuration for cloud Jupyter environments, including its own environment.yml and post-build scripts.
  • translations/ – Multi-language rendered versions of the curriculum (e.g., zh-TW/, zh-CN/).
  • data/ – Binary datasets used by notebooks.

Practical Workflow

Clone and explore the repository using this sequence:


# Clone the repo

git clone https://github.com/microsoft/AI-For-Beginners.git
cd AI-For-Beginners

# Top-level view

ls -l

# Full recursive list

ls -R | less

# Pretty tree view of lessons

tree -L 2 lessons/

Scripting Examples for Advanced Navigation

Generate a Repository Overview Script

Create a reusable script to display the top-level directory structure:

#!/usr/bin/env bash

# print_tree.sh – shows a concise view of the repo's top-level structure

repo_root=$(git rev-parse --show-toplevel 2>/dev/null || echo ".")
echo "Repository root: $repo_root"
tree -d -L 2 "$repo_root"

Make it executable and run:

chmod +x print_tree.sh
./print_tree.sh

Count Files per Directory

Analyze the distribution of content across the curriculum:

for d in */ ; do
  echo "$d: $(find "$d" -type f | wc -l) files"
done

Locate Specific File Types

Find all Jupyter notebooks to map the lesson content:

find . -name "*.ipynb" | sort

This outputs paths like:


./lessons/1-Intro/01-What-is-AI/Intro.ipynb
./lessons/2-Symbolic/Animals.ipynb

Summary

  • Use tree -L 3 for the most readable visual overview of the microsoft/AI-For-Beginners directory structure.
  • Use ls -R when you need a complete linear listing without installing additional tools.
  • Use find . -type d -maxdepth 2 to map only the folder hierarchy, ignoring individual files.
  • The repository organizes content into lessons/ (notebooks), etc/ (quiz-app), examples/ (scripts), and data/ (datasets).
  • Reference environment.yml in the root and binder/ subdirectory for environment setup configurations.

Frequently Asked Questions

What is the difference between ls -R and tree?

ls -R lists all files recursively in a linear, vertical format that can be difficult to read for deep hierarchies, while tree displays the directory structure in a visual, indented tree diagram that clearly shows parent-child relationships. The tree command is preferred for repositories like AI-For-Beginners because it makes the nested lessons/ structure immediately apparent.

How do I view only directories and hide files in Bash?

Use the find command with the -type d flag: find . -type d -maxdepth 2. Alternatively, if you have tree installed, run tree -d to display only directories without files. This is useful when you want to understand the curriculum organization in lessons/ without seeing the individual .ipynb and .py files.

How can I check which directories consume the most disk space?

Run du -h --max-depth=1 | sort -hr to display directory sizes in human-readable format sorted from largest to smallest. This helps identify heavy directories like data/ that contain binary datasets such as mnist.pkl.gz before you attempt to copy or backup the repository.

How do I list only Jupyter notebooks in the repository?

Execute find . -name "*.ipynb" | sort to recursively locate and alphabetically sort all Jupyter notebook files. This command reveals the complete lesson structure within lessons/ and helps you identify specific curriculum files like lessons/1-Intro/01-What-is-AI/Intro.ipynb without navigating through each subdirectory manually.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →