exa: A Modern Replacement for the ls Command

I bet you have used the ls command in Linux. It’s one of the first command you use while learning Linux commands.

The simple ls command is quite handy for listing directory content. I never really though any command could replace it until I discovered exa.

What is exa command?

exa is a command line tool that lists directories and files in the specified path (or in the current directory if not specified). This might sound familiar to you because it is exactly ls command also does.

exa is supposed to be a modern replacement for the venerable ls command from the good old UNIX days. It has more features and better default than the ls command, so it claims.

exa features
exa features | Courtesy exa project website

Here are some reasons why you would want to use the exa command instead of ls:

  • exa is just as portable as ls (available on all major Linux distributions, *BSD and macOS)
  • Has colorful output by default
  • The differently formatted “verbose-ness” of exa might attract users who are new to Linux/BSDs
  • File querying is done in parallel, making exa equivalent or on par to the performance of ls
  • Shows git staged or un-staged status for individual files

One of the other aspect of exa is that it is written in the Rust programming language. In case you don’t know about the Rust language, it has similar execution speed compared to C while cutting down memory related errors at compile time itself; making your software fast and secure.

Installing exa on your Linux system

exa has gained quite some popularity lately and thus many distributions have started including it in the official repositories. In other words, you should be able to install it using your distribution’s package manager.

Starting with Ubuntu 20.10, you can install it using the apt command:

sudo apt install exa

Arch Linux already has it so just use the pacman command:

sudo pacman -S exa

If it is not available through your package manager, don’t fret. It’s a Rust package after all and you can easily install it with Cargo. Please make sure to install Rust and Cargo on Ubuntu or whichever distribution you are using.

Once you have Rust and Cargo installed, use this command to install exa:

cargo install exa

Using exa

exa has a lot of command options, mostly aimed at a better formatted output and some quality of life improvements like git status for staged or unstaged file, and much more.

Below are a few screenshots demonstrating how exa will work on your system.

Simply using the exa command will produce an output similar to ls but with color. This color thing may not be that attractive because distributions like Ubuntu already provide colored ls output at least in desktop version. However, the ls command doesn’t have colored output by default.

01 exa
A screenshot of the exa command’s output without any additional flags

Please note that exa and ls command do not have all the same options. For example, while the -l option gives long list in both exa and ls, the -h option adds a column header instead of the human readable option like ls.

exa -lh
02 exa lh
exa has column titles for a better “verbose-ness” as I mentioned before

I told you that exa has built in git integration. The screenshot below gives the demonstration of the –git flag. Notice how the test_file shows -N in tracked column of git because it has not been added to the repository sources yet.

exa --git -lh
03 exa git
Demonstration of how the git flag works with exa

The example below is not something my cat typed. It’s a combination of various options. Exa has even more options for you to try and explore.

exa -abghHliS
04 exa all flags
A very colorful and detailed output with user friendly verbose output

You can get the full list of options by running the following command in your terminal:

exa --help

However, if you want to see what exa has to offer, you can view the official documentation on its git repository.

Worth switching to exa from ls?

As user friendly as exa might be to someone who is new to UNIX like Operating Systems, it trades the ability of being easily used in a script for “easy-ness” and appearance. Which, to be clear is not a bad thing.

In any case, ls is like the universal command. You may use exa for personal use but when it comes to scripting, stick to ls. The difference of one [or many] flags between ls and exa might drive you crazy when the expected output does not match the actual output in either command.

I would like to know your views on exa. Have you already tried it? How’s your experience with it?

Similar Posts

  • Ohh, that is so cool! I had a great time be-bopping all over my ~/ files, mostly, but did venture up to the very top and even with colo[u]r=WHEN set to always, and colo[u]r-scale enabled, there is not much to see, even with -a and (I think this one is new) [email protected] for extended info, root just does not want to give up many secrets…or colo[u]rs. Yeah, the man file as well as the –help list really does put the regex optional u in colors. I think it is cool. You guys gotta try it. Once you go exa, you never uh… you never go back to ls and the boring effect-sa. No I am not Jar-Jar Binks! lol I had to make it rhyme somehow. The obvious one (cough…19th letter! cough) excuse me…sorry about that. About the obvious now-elephant-in-the-room card is pulled and I wanted to keep it clean. I gotta show some respect-sa! Aww, man! I forgot about that one! Anyway, try the new exa. You will be impressed. Really.
    MichaelTheGamer (too lazy to sign in)

    • If your install went to that directory, you can simply copy the install from the ~/.cargo/bin to the /usr/bin. Using an example, if you installed exa, you take the binary of binary and type this into your terminal: “sudo cp exa /usr/bin”. Or you can move it from that folder, your choice.