eza ls Replacement

eza cheatsheet — list files with git status, icons, tree view. eza -la --git, eza --tree --level=3, eza --icons. The modern ls replacement with color and context.

4 min read

What it is

eza is a modern replacement for the standard ls command, offering enhanced features like Git integration, syntax highlighting, and tree views.

Installation

Linux (using package managers):

# Debian/Ubuntu
sudo apt update && sudo apt install eza

# Fedora
sudo dnf install eza

# Arch Linux
sudo pacman -S eza

Linux (using Cargo):

cargo install eza

Mac (using Homebrew):

brew install eza

Windows (using Scoop):

scoop install eza

Windows (using Cargo):

cargo install eza

Commands / Usage

Listing Files and Directories

  • List files and directories in the current directory:

    eza
    

    Lists files and directories with default formatting.

  • List all files, including hidden ones:

    eza -a
    

    Shows all entries, including those starting with a dot (.).

  • List files with details (permissions, size, owner, date):

    eza -l
    

    Provides a long listing format.

  • List files with human-readable file sizes:

    eza -lh
    

    Displays sizes in KB, MB, GB, etc.

  • List files recursively (show subdirectories):

    eza -R
    

    Lists contents of subdirectories as well.

  • List files in a tree-like format:

    eza --tree
    

    Displays directory structure in a visual tree.

  • List files sorted by modification time (newest first):

    eza -lt
    

    Sorts output by time.

  • List files sorted by size (largest first):

    eza -lS
    

    Sorts output by file size.

  • List files sorted by extension:

    eza -lX
    

    Sorts output alphabetically by file extension.

  • List files with Git status:

    eza -lg
    

    Shows Git status for files in a Git repository.

  • List files with Git status and highlight unread files:

    eza -lgh
    

    Combines Git status with highlighting for new/modified files.

  • List files with specific color themes:

    eza --color=always
    

    Forces color output, useful for piping.

    eza --color=auto
    

    Enables color output when outputting to a terminal.

    eza --color=never
    

    Disables color output.

  • List files with icons:

    eza -G
    

    Displays icons next to files and directories (requires a Nerd Font).

Filtering and Searching

  • List only directories:

    eza -d
    

    Shows only directories.

  • List only files:

    eza -f
    

    Shows only files.

  • List files matching a pattern:

    eza "*.txt"
    

    Lists all files ending with .txt.

  • List files larger than a specific size:

    eza -l --size +1M
    

    Lists files larger than 1 megabyte.

  • List files modified within a specific time frame:

    eza -l --time-days 7
    

    Lists files modified in the last 7 days.

Display Options

  • Show file permissions as octal:

    eza -lo
    

    Displays permissions in numeric (octal) format.

  • Show file permissions as symbolic links:

    eza -l --links
    

    Displays symbolic links with their target.

  • Show file owner and group:

    eza -lug
    

    Displays the user and group owner of files.

  • Show file inode number:

    eza -li
    

    Displays the inode number for each file.

  • Display file type indicators:

    eza -F
    

    Appends symbols to indicate file types (e.g., / for directories, * for executables).

  • Control displayed columns:

    eza -l --columns 3
    

    Displays output in 3 columns.

  • Hide specific file types:

    eza -a --ignore-glob="*.log"
    

    Lists all files except those ending with .log.

Aliases and Configuration

  • Create an alias for common eza usage: Add this to your shell’s configuration file (e.g., ~/.bashrc, ~/.zshrc):
    alias ls='eza --icons'
    alias ll='eza -l --icons'
    alias la='eza -la --icons'
    alias lt='eza --tree --icons'
    
    This allows you to use ls, ll, etc., with eza’s features.

Common Patterns

  • Get a detailed, human-readable, and iconized listing of all files in the current directory:

    eza -lahG
    

    This is a very common and informative way to view directory contents.

  • See the Git status of your project’s files:

    eza -lg
    

    Quickly identify modified, added, or untracked files in a Git repository.

  • Find the largest files in a directory:

    eza -lSh | head
    

    Lists files by size (largest first) and shows the top 10.

  • View a directory’s structure in a tree format with icons:

    eza --tree -G
    

    Great for understanding nested directories.

  • Pipe eza output to other commands:

    eza -l | grep "myfile"
    

    Find a specific file within a detailed listing.

    eza -a | wc -l
    

    Count the total number of files and directories (including hidden ones).

Gotchas

  • Nerd Fonts Required for Icons: The -G (or --icons) flag relies on Nerd Fonts being installed and your terminal emulator configured to use them. If you don’t see icons, this is likely the reason.
  • Default ls Behavior: If you alias ls to eza, be aware that some scripts might explicitly call the original ls command and expect its exact output format.
  • Git Integration Requires Git: The Git-related flags (-g, --git) only work within a Git repository and require Git to be installed.
  • Color Output with Pipes: When piping eza’s output to another command, colors might be included by default, which can sometimes interfere with parsing. Use --color=never or --color=auto (if the receiving command handles it) to manage this.
  • --time-days vs. --time-seconds: Be mindful of the time units when filtering by time. --time-days is relative to the current day, while --time-seconds is a strict timestamp comparison.