Why You Should Replace ‘ls’ With ‘exa’ Linux Command For Listing Files

It comes with a Git support and built-in tool for printing tree-view output.

Share on twitter
Tweet
Share on whatsapp
WhatsApp
Share on facebook
Share

If you use a Linux and Unix-like operating system, you will definitely be familiar with or used the ls command-line utility. It lists information about files or directories. Being decades-old command, ls has not improved a lot to bring modern functionality that you may be wanting, for instance, Git support, colorful, and tree view output. Here’s where exa tool comes as the modern ls alternative.

Exa: ‘ls’ Alternative Listing Command Written In Rust

Similar to ls, exa is also a free and open source command-line utility that lists files. However, exa is small, fast, and user-friendly with more features and better query performance.

If your day involves listing and interacting with hundreds of files, exa can help you reduce your lot of efforts by displaying output in a few seconds using the parallel query.

Not just a fast query, but it can be helpful in easily recognizing the file types and metadata, which is colored differently based on the file extensions by default.

exa vs ls
exa vs ls

As you can see in the above picture, exa also prints human-readable file sizes by default. While you need to use -h or --human-readable option for ls command.

Moreover, exa comes with a built-in tool for printing tree-view output that you can also combine with file information.

tree view output
tree view output

And the most interesting feature that distinguishes exa from ls is the support for the Git version control system.

If you are inside your Git repository and want to see if any files changed or modified since the last commit without installing Git and using git status, you can use –git option with exa. It adds a new Git column in the metadata table containing two characters that depict staged or unstaged status.

Git Integration
Git Integration

How To Install Exa On Ubuntu And Other Linux Distros?

Interestingly, exa is a standalone binary that doesn’t require any dependencies to be installed. The only thing you need to install it is to download a binary for your OS and place it in a directory (most probably /usr/bin/) listed in $PATH environment variable.

However, if you find this manual method difficult, another (easiest) way to install exa is using the default package manager of your system.

For Debian and Ubuntu 20.10+, you can run:

$ sudo apt install exa

On Arch,

$ pacman -S exa 

On Fedora,

$ dnf install exa

For Gentoo,

$ emerge sys-apps/exa

On openSUSE,

$ zypper install exa

On Fedora,

$ dnf install exa

Furthermore, if you use macOS and already have a Homebrew package manager installed, run the following command:

$ brew install exa

At last, you can also compile and built it using the source code, required dependencies, and following the instruction given here.

How To Use Exa?

List Files With Meta Data

Using --long or -l option, you can displays files along with their metadata.

$ exa -l
list metadata
list metadata

And if you don’t know what each column in metadata means, you can use the same option along with --header or -h that adds a new row defining each column.

$ exa -lh
exa output with header
exa output with header

Displays Content Of A Directory

Instead of the current directory, if you want to list the all content of a particular directory, you can directly pass the directory path as an argument.

$ exa <directory-path>
list directory
list directory

List Files In All Directories And Subdirectories

To list directories and subdirectories recursively, you can --recurse or -R option. It creates a separate listing for each sub-directory.

$ exa -R
recurse subdirectory
recurse subdirectory

List Content Of Directory In Tree-Like Format

Since exa has a built-in tool that displays content tree-like format recursively, you don’t need an extra command like a tree. You can just pass --tree or -T option and it will list the content of all directory and sub-directory in a tree structure.

$ exa -T
Tree format output
Tree format output

If you want to view the content of subdirectory to a particular extent, you can also limit the depth of recursion using -L or --level=(depth) option.

$ exa -L 2
tree-format output with limited depth
tree-format output with limited depth

Disable Colorful Output

Not a fan of viewing colorful terminal output? Well, exa also accept --color option with values always, automatic, and never. If you want to disable the color, pass --color=never argument.

$ exa --long --color=never
exa output with color disabled
exa output with color disabled

If you want to get the most out of the exa utility, you can read its official documentation.

Do you think the time has come to replace ls with exa command or you’ve already done it? Do let us know in the comment below.

Sarvottam Kumar

Sarvottam Kumar

Sarvottam Kumar is a software engineer by profession with interest and experience in Blockchain, Angular, React and Flutter. He loves to explore the nuts and bolts of Linux and share his experience and insights of Linux and open source on the web/various prestigious portals.
Scroll to Top