Exa – A Modern Replacement for “ls Command” Written in Rust
Last Updated :
15 Nov, 2023
The ls command has been a staple of the Unix and Unix-like operating systems for decades. It’s a simple and effective tool for listing the contents of a directory. However, in recent years, developers and system administrators have been seeking alternatives to the traditional ls command that offer more features, better performance, and a more aesthetically pleasing output. One such alternative that has gained popularity is “Exa,” a modern replacement for the ls command, written in Rust.
Installing Exa
To start using Exa as a replacement for the ls command, you need to install it on your system. Installation methods vary depending on your operating system:
On Linux (via Package Manager):
Fedora / Red-Hat based:
Using dnf or yum package manager:
sudo dnf install exa
sudo dnf install exa
Ubuntu/Debian based:
Using apt package manager:
sudo apt install exa
sudo apt install exa
On macOS (via Homebrew):
Using brew package manager:
brew install exa
Why ‘Exa’ not ls?
Exa, created by Benjamin Sago, is a modern and feature-rich replacement for the traditional ls command.
exa vs ls
From the above figure you can see, compared to ls exa offers numerous advantages:
- Enhanced output formatting with color-coded, human-readable listings for easy file type and permission identification
- Versatile sorting and filtering options,
- Excellent Git integration for developers
- File icons and metadata display for additional information,
- Cross-platform support on Unix-like systems
- Superior performance thanks to Rust’s memory safety and speed advantages.
Options available with Exa command
The “exa” command in Linux offers several options for file and directory listing. These options enhance its functionality and provide different ways to view and manage your files and folders. Here are the few available options with a brief description of each:
Long listing of files and folders
|
Show header names for columns in a long lasting
|
Display appropriate icons for files/folders
|
Filter files and folders using glob patterns
|
Sort files/folders based on the given argument (name, size, etc.)
|
Display a tree view of the folder
|
Show output in the default grid view
|
Display changes in the local Git repository
|
Basic usage of Exa
Once Exa is installed, you can use it just like the traditional ls command. Here are some basic usage examples:
List files/folders:
Syntax:
exa
Just like the ls command, this command will list the contents of the current directory and uses different colors to improve readability.
exa
List Files with Details (Long view):
Syntax:
exa -l
-l: Enables long listing, displaying detailed information about files and directories, including permissions, owners, sizes, and timestamps.
exa -l
Show hidden files/folders
Syntax:
exa -a
Just like ‘ls’ you can use the -a option to list the hidden files/folders. This command will display all files and directories in the current directory, both the visible and hidden ones, helping you gain a comprehensive view of the contents within that directory.
exa -a
Show header for columns in the long view
Syntax:
exa -l --header
–header: Shows header names for columns in long listing mode, making it easier to understand the information presented.
Show file/folder icons:
Syntax:
exa --icons
–icons: Displays appropriate icons for files and folders, adding a visual element to the listing.
Advanced usage of Exa
Filtering files and folders
Syntax:
exa --ignore-glob=<pattern>
–ignore-glob=<pattern>: Exa enables you to specify a list of glob patterns for exclusion. When a file’s name aligns with any of these patterns, it will be omitted from the displayed list.
exa –ignore-glob=’*secret*’
Sorting files and folders
Syntax:
exa --sort=<argument>
–sort=<argument>: With the –sort option you have the flexibility to determine the order in which files are displayed using the –sort option. This option accepts an argument that defines the specific criteria or field by which the files should be sorted.
The following arguments are accepted:
- name or filename
- size or filesize
- ext or extension
- .name or .filename
- mod or modified
- old or oldest
- acc or accessed
- cr or created
- inode
Example:
Sorting files/folders based on creation date and time.
exa –sort=cr
TreeView (a substitute for the tree command)
Syntax:
exa -T
Using -T or –tree with exa generates a tree view, which shows files and folders inside the current folder and subdirectories, so you can easily see how everything is organized and where files are located.
exa -T –icons
Grid view
Syntax:
exa --grid
Exa defaults to the grid view when no specific options are provided. In this view, each file name is presented in a grid format that adjusts to the current terminal window’s size, with the column widths adapting to accommodate the displayed filenames.
exa -l –header –icons –grid
Git integration
Syntax:
exa --git
–git: Displays changes in the local Git repository within the directory, allowing you to see version control status.
- N: New file/folder
- M: Modified file
exa -l –header –icons –git
Conclusion
Exa is a modern and feature-rich replacement for the traditional ls command that offers improved output formatting, enhanced sorting and filtering options, Git integration, icons, and metadata display. It’s written in Rust, making it a cross-platform and efficient alternative for Unix-like operating systems. Whether you’re a developer, system administrator, or an everyday user, Exa can enhance your experience when working with the filesystem. Give it a try, and you might find yourself making it your new default directory listing tool. To learn more check out the official documentation of Exa.
Share your thoughts in the comments
Please Login to comment...