The ls command is one of the basic yet essential Linux commands. You cannot imagine surviving the terminal without it.
And yet, there is a new tool that aims to be a replacement of the ls command. This new tool is exa.
How audacious! But exa actually is full of intuitive features that you won't find in the ls command. Some of them are:
- Colorful output
- Grid, long, and tree view
- Git integration
- Display icons
Intrigued? Let me tell you how to install exa and use it.
You should get it in the official repositories of most distributions.
For Debian and Ubuntu-based distributions, use:
sudo apt install exa
If you are on an Arch-based distro, you should use:
pacman -S exa
For Fedora users, use the DNF command:
dnf install exa
Since exa is based on Rust, it can also be installed using the cargo package manager.
First set up cargo on Linux and then exa can easily be installed with the following command:
cargo install exa
If you want to take the matter into your hands, you can build it from the source by following their official documentation.
Using exa command
The best part is that the exa command syntax is pretty similar to the ls so there is no steep learning curve here.
The exa uses specific colors for specific file types.
So for your reference, I stacked multiple types of files in one directory and listed them in a tree manner which will indicate their colors:
And as you can see, it indicated all the files using different colors such as compressed files are shown with bright orange and the documents are listed with lavender color.
Now, let's explore other use cases of exa.
To enable the grid view, all you need to do is append the
--grid flag with the exa command:
By default, it will sort the files respective to columns so you will see that numbers on the first column sort files.
Now, this behavior can be altered for rows in which the files will be sorted respective to columns using the
And if you want to list the files in a single column, you can use the
--oneline flag with the exa command:
You can think of the long view as typical the
ls -la output that brings permissions, filesize, etc.
To access the long view, all you need to do is append the
--long flag with the exa command:
But it feels pretty plain and I prefer to have headers and an extra column specifying the user group.
To enable headers and a user group column, you'll have to add two extra flags
exa --long --header --group
And if you want to have a combination of list and grid view, you can append both
--grid to the exa command:
exa --long --grid
Pretty cool. Right?
exa can display the content like the tree command. To list files in the tree manner, all you need to do is append the
-T option with the exa command:
To sort files based on their size, you will have to use the
--sort=size flag with the exa command:
exa --long --header --sort=size
Similarly, you can use different options as following to sort :
|--sort=name||Sort files based on names (Alphabetically).|
|--sort=acc||Sort files based on when they were accessed.|
|--sort=cr||Sort files based on the time they were created or changed.|
|--sort=mod||Sort files based on the time of modification (from oldest to newest).|
|--sort=ext||Sort files based on the filename's extension.|
Exa is one of the modern alternatives to the legendary UNIX commands.
In my opinion, the ls command is a classic and cannot be replaced. The exa command gives an option to Linux users who completely control their system.
For sysadmins who have to work on different servers in different environments, relying on exa won't be possible. The ls command is omnipresent, exa is not.
Still, it is good to see such modern takes on the classic Linux commands.