A modern replacement for the ls command
I bet you have used the ls command in Linux. This is one of the first commands you use when learning Linux commands.
The simple ls command is very handy for listing the contents of the directory. I never really thought a command could replace it until I discovered exa.
What is the 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 may sound familiar to you because it is exactly the ls command that also does this.
exa is meant to be a modern replacement for the venerable ls command from the good old UNIX days. It has more features and a better default than the ls command, it claims.
Here are some reasons why you might 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 colored output by default
- exa’s differently formatted “verbose-ness” might appeal to users who are new to Linux/BSD
- File querying is done in parallel, making exa equivalent or on par with the performance of ls
- Shows staged or unstaged git status for individual files
One of the other things about exa is that it’s written in the Rust programming language. If you’re unfamiliar with the Rust language, it has a C-like execution speed while reducing memory-related errors at compile time itself; make your software fast and secured.
Install exa on your Linux system
exa has gained popularity lately, so many distributions have started including it in official repositories. In other words, you should be able to install it using your distro’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, just use the pacman command:
sudo pacman -S exa
If it’s not available through your package manager, don’t worry. It is a Rust package after all and you can easily install it with Cargo. Be sure to install Rust and Cargo on Ubuntu or whatever distribution you are using.
Once Rust and Cargo are installed, use this command to install exa:
cargo install exa
exa has a lot of command options, mostly for better formatted output and some quality of life improvements like git status for staged or unstaged files and much more.
Below are some screenshots showing how exa will work on your system.
Simply using the exa command will produce output similar to ls but with color. This color may not be so appealing because distros like Ubuntu already provide colored ls output at least in the desktop version. However, the ls command does not have colored output by default.
Please note that not all exa and ls commands have the same options. For example, while the -l option gives a long list in exa and ls, the -h option adds a column header instead of the human readable option like ls.
I told you that exa has integrated git integration. The screenshot below demonstrates the –git flag. Notice how the test_file shows -N in the column followed by git because it hasn’t been added to the repository sources yet.
exa --git -lh
The example below is not something my cat typed. It is a combination of various options. Exa has even more options to try and explore.
You can get the full list of options by running the following command in your terminal:
However, if you want to see what exa has to offer, you can check out the official documentation on its git repository.
Is it worth switching to exa from ls?
As user-friendly as exa may be for someone new to UNIX like operating systems, it trades the ability to be easily used in a script for “ease” and looks. Which, to be clear, isn’t a bad thing.
Either way, ls is like the universal command. You can use exa for personal use, but when it comes to scripting, stick to ls. The difference of a [or many] the flags between ls and exa can drive you crazy when the expected output does not match the actual output in either command.
I would like to know your point of view on exa. Have you ever tried? How is your experience with it?