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.
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
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.
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.
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
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.
You can get the full list of options by running the following command in your terminal:
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?