Linux Directory Structure Tools
A collection of commands and tools for exploring and visualizing directory structures in Linux.
Tree Command
Section titled “Tree Command”Displays directory structure in a tree-like format:
sudo apt install tree -y
tree # Current directorytree -L 2 # Limit to 2 levelstree -d # Directories onlytree -h # Include file sizesExample output:
.├── documents│ ├── work│ └── personal├── downloads└── pictures ├── 2023 └── 2024
6 directoriesList Command (ls)
Section titled “List Command (ls)”Traditional directory listing:
ls -R # Recursive listingls -la # Detailed list with hidden filesls -lh # Human readable sizesExample output:
drwxr-xr-x 4 user user 4.0K Dec 22 10:30 documentsdrwxr-xr-x 2 user user 4.0K Dec 22 10:30 downloadsdrwxr-xr-x 4 user user 4.0K Dec 22 10:30 picturesFind Command
Section titled “Find Command”Search and explore directories:
find . -type d # List all directoriesfind . -type f # List all filesfind . -maxdepth 2 # Limit search depthExample output:
../documents./documents/work./documents/personal./downloads./pictures./pictures/2023./pictures/2024Advanced Usage: File Content Explorer
Section titled “Advanced Usage: File Content Explorer”View directory structure with file contents:
tree -if --noreport | while read file; do if [ -f "$file" ]; then echo "=== $file ===" cat "$file" echo fidoneExample output:
=== ./config.yml ===server: port: 8080 host: localhost
=== ./readme.md ===# Project READMEThis is a sample project...Common Options
Section titled “Common Options”-a: Show hidden files-h: Human readable sizes-L n: Limit depth to n levels-d: Directories only-f: Full path prefix
These tools are invaluable for system administration, documentation, and understanding directory hierarchies.