Step-by-step guide to Install and use exa Command on Linux. Learn tree view and Git integration. The world of Linux commands is vast and continuously evolving. While some tools have remained unchanged for decades, innovative alternatives emerge that enhance productivity and user experience. One such tool is exa, a modern replacement for the traditional ls command. If you’ve spent any time in the Linux terminal, you’re familiar with ls for listing files. However, exa takes this fundamental functionality to the next level with improved features, better visual presentation, and enhanced capabilities for today’s development workflows.
This comprehensive guide will explore how to install exa across various Linux distributions, understand its basic and advanced features, and effectively incorporate it into your daily terminal usage. Whether you’re a system administrator, developer, or Linux enthusiast, exa can significantly improve your file management experience.
What is exa?
Definition and Basic Concept
exa is a modern, feature-rich replacement for the traditional ls command that comes pre-installed on all Unix and Linux operating systems. Written in Rust, a programming language known for its speed, safety, and parallelism, exa provides enhanced file listing capabilities with a more user-friendly approach. The command offers a visually appealing alternative to the plain, often difficult-to-parse output of ls.
Key Features and Advantages
What sets exa apart from the conventional ls command is its extensive feature set. exa uses colors intelligently to distinguish file types and metadata, making it easier to identify different files at a glance. It offers better integration with modern development tools and workflows, particularly through its Git awareness capabilities.
Some of exa’s standout features include:
- Color-coded output for different file types and attributes
- Git integration for repository status display
- Tree view functionality
- Parallel file querying for faster performance
- Extended attributes display
- More intuitive default options
Why Consider Using exa?
While ls has served the Linux community well for decades, exa addresses many of its limitations. The color-coded output makes scanning directories faster and more intuitive. The Git integration is particularly valuable for developers who frequently work with repositories. Additionally, exa’s modern design makes it more aligned with contemporary development practices and requirements.
System Requirements
Hardware Requirements
One of exa’s advantages is its minimal hardware requirements. It runs efficiently on virtually any system capable of running a modern Linux distribution. As a lightweight command-line utility, exa doesn’t demand significant computational resources to perform effectively.
Software Prerequisites
To install and use exa, you’ll need:
- A Linux distribution or macOS (exa works across multiple platforms)
- For certain installation methods, you may need the Rust programming environment
- For Git integration features, libgit2 is required
- Some installation methods require development packages and build tools
The specific dependencies may vary based on your chosen installation method. If you’re installing via package managers, dependencies are typically handled automatically.
Installation Methods
exa can be installed through various methods, from simple package manager commands to manual compilation. Let’s explore the different approaches based on your Linux distribution.
Using Package Managers
Debian/Ubuntu-based Systems
For Ubuntu 20.10 (Groovy Gorilla) and later versions, exa is available in the official repositories:
sudo apt update
sudo apt install exa
For Ubuntu 20.04 or earlier versions, a manual installation method is recommended.
Red Hat/Fedora/CentOS Systems
On Fedora and RHEL-based distributions, you can install exa using:
sudo dnf install exa
For CentOS, the command would be:
sudo yum install exa
Arch Linux and Derivatives
If you’re using Arch Linux or an Arch-based distribution like Manjaro:
sudo pacman -S exa
OpenSUSE
OpenSUSE users can install exa with:
sudo zypper install exa
Alpine Linux
On Alpine Linux, you’ll need to enable the community repository first, then:
apk add exa
Gentoo
For Gentoo users:
sudo emerge sys-apps/exa
Manual Installation Methods
Binary Downloads
For distributions without exa in their repositories, or if you want the latest version:
- Determine the latest version:
EXA_VERSION=$(curl -s "https://api.github.com/repos/ogham/exa/releases/latest" | grep -Po '"tag_name": "v\K[0-9.]+')
- Download the appropriate binary:
curl -Lo exa.zip "https://github.com/ogham/exa/releases/latest/download/exa-linux-x86_64-v${EXA_VERSION}.zip"
- Extract and install:
sudo unzip -q exa.zip bin/exa -d /usr/local
- Verify installation:
exa --version
- Clean up:
rm -rf exa.zip
Building from Source
If you prefer to build from source, you’ll need Rust installed:
- Clone the repository:
git clone https://github.com/ogham/exa.git
- Navigate to the directory:
cd exa
- Build the project:
cargo build --release
- Install the binary:
sudo cp target/release/exa /usr/local/bin/
Using Cargo
If you already have Rust and Cargo set up:
cargo install exa
This will build and install exa to $HOME/.cargo/bin
.
Basic Usage
Once installed, exa can be used similarly to the traditional ls command but with enhanced functionality. Here’s how to get started with the basics.
Simple File Listing
To list files in the current directory:
exa
This provides a more visually appealing output than the standard ls command, with files colored according to their types.
Common Options and Flags
For a long format listing with detailed information:
exa -l
This displays permissions, owner, group, size, modification date, and file names.
To display files in a grid format:
exa -G
For one entry per line:
exa -1
To sort files (by name, size, etc.):
exa -s name
exa -s size
For reverse ordering:
exa -r
Listing Hidden Files
To show hidden files (those starting with a dot):
exa -a
This will display all files including hidden ones, similar to ls -a
.
Permission and Ownership Display
exa’s color-coded permissions make it easier to understand file access rights at a glance. The long format view shows:
exa -l
The output includes:
- File permissions (read, write, execute)
- Owner and group information
- File size
- Last modified timestamp
- File name
This information is presented in a more readable format than traditional ls output.
Advanced Features
exa’s power becomes evident when exploring its advanced features, which extend well beyond basic file listing.
Color Coding and Visual Elements
exa uses an extensive color scheme to differentiate between file types, permissions, and other attributes. This visual distinction makes it significantly easier to scan directory contents quickly.
Different colors represent:
- Directories
- Executable files
- Symlinks
- Special files
- Git status indicators
- And many more
The color coding is intelligent and consistent, making directory navigation more intuitive.
Directory Navigation
For recursive listing of directories:
exa -R
One of exa’s most powerful features is the tree view, which displays directories in a hierarchical structure:
exa -T
To limit recursion depth:
exa -T -L 2
This would display a tree view with a maximum depth of 2 levels.
Git Integration
For developers, exa’s Git integration is invaluable. To display Git status alongside files:
exa --git
This shows indicators like:
- N: New file
- M: Modified file
- D: Deleted file
- ??: Untracked file
This feature eliminates the need to run separate git status commands while navigating repositories.
Filtering and Sorting
exa offers powerful filtering and sorting capabilities:
exa --sort=size
exa --sort=modified
For directory-first sorting:
exa --group-directories-first
You can also filter by file type:
exa -I "*.tmp"
This would exclude all .tmp files from the listing.
Customization and Configuration
Creating Aliases
To streamline your workflow, consider creating aliases for commonly used exa commands. You can even replace ls entirely:
Add these lines to your ~/.bashrc
or ~/.zshrc
:
alias ls='exa'
alias ll='exa -l'
alias la='exa -a'
alias lt='exa -T'
alias llg='exa -l --git'
After adding these aliases, don’t forget to reload your shell configuration:
source ~/.bashrc
Configuration Files
While exa doesn’t use a dedicated configuration file, you can set environment variables to control certain behaviors. For example:
export EXA_COLORS="di=1;34:ln=1;36:*.png=33"
This would customize the color scheme for directories, links, and PNG files.
For more permanent settings, you can add these configurations to your shell’s initialization files.
Performance Considerations
Speed Comparison with ls
exa is generally fast and responsive, but it’s worth noting that it may be slightly slower than ls in some scenarios. This is because exa processes more information to provide its enhanced features.
However, for most everyday use, the performance difference is negligible, and the additional features more than compensate for any minimal delay.
Resource Usage
Because exa is written in Rust, it benefits from the language’s efficiency and memory safety. It uses parallel processing for file querying, which can actually make it faster than ls when listing large directories with many files.
For very resource-constrained environments, you might want to use basic options and avoid recursive operations on extremely large directory structures.
Practical Examples and Use Cases
Development Workflows
For developers working with Git repositories:
exa -l --git
This command provides a comprehensive view of file status within a repository, showing both file details and Git status indicators.
For navigating complex project structures:
exa -T -L 2 --git
This displays a tree view of the project with Git status information, limited to two levels deep.
System Administration Tasks
For system administrators auditing permissions:
exa -l --group
This places emphasis on group ownership, which is helpful when managing shared resources.
For checking recently modified files:
exa -l --sort=modified
This sorts files by modification time, with the most recently changed files appearing at the bottom of the list.
Daily Usage Scenarios
For a quick overview of directory contents with sizes:
exa -la --group-directories-first
This displays all files (including hidden ones) with directories listed first.
When searching for specific files:
exa | grep "config"
This can be combined with other commands like grep for powerful file searching capabilities.
Troubleshooting Common Issues
Installation Problems
If you encounter “command not found” errors after installation, ensure that the installation path is included in your PATH environment variable.
For cargo installations, you might need to add ~/.cargo/bin
to your PATH:
export PATH="$HOME/.cargo/bin:$PATH"
Add this line to your ~/.bashrc
or equivalent configuration file.
Runtime Errors
If you see dependency-related errors, install the required libraries:
sudo apt install libgit2-dev # For Git integration
For display issues with icons or colors, check your terminal’s color support and font configuration. Some features may require a terminal that supports 256 colors.
If you’re using sudo and exa isn’t found, remember that sudo typically uses a different PATH. Use the full path to exa or configure sudo to preserve your PATH.