How to Use the ‘exa’ Command in Linux

Say goodbye to "ls" and hello to "exa" for a refreshed Linux journey.

The exa Linux command is more than just a file lister; it’s a modern replacement for the well-known ls command, offering enhanced features and a more visually appealing display. With its color-coded output and flexible options, exa provides a comprehensive view of your files and directories.

While the traditional ls command has been a staple in Linux, exa takes it a step further by offering better integration with other commands and tools. Whether you’re a seasoned professional managing large servers or a hobbyist tinkering with a home setup, the exa command can be a valuable addition to your toolkit. Used in conjunction with commands like grep and find, exa allows for more efficient file searching and manipulation, streamlining your workflow and enhancing your command-line experience.

How to Install the exa Command

exa is not typically included by default in most Linux distributions, so you’ll need to install it. Here’s how you can install exa on some common Linux distributions:

Ubuntu/Debian

You can install exa from the package manager using the following commands:

sudo apt update
sudo apt install exa

Fedora

On Fedora, you can use the following command:

sudo dnf install exa

Arch Linux

If you’re using Arch Linux, you can install exa from the AUR:

yay -S exa

From Source

If exa is not available in your distribution’s package manager, or if you want the latest version, you can compile it from source. You’ll need to have Rust installed to do this:

git clone https://github.com/ogham/exa.git
cd exa
cargo build --release
sudo cp target/release/exa /usr/local/bin/

Precompiled Binaries

You can also download precompiled binaries from the official GitHub releases page and place them in your PATH.

After installation, you can run exa from the command line just like you would with ls or any other command-line tool.

How to Use exa

1. Basic Listing

Syntax: exa

Explanation: Lists files and directories in the current directory.

Example: exa

Output:

Documents  Pictures  Videos

Displays the names of three directories: Documents, Pictures, and Videos.

2. Long Format

Syntax: exa -l

Explanation: Displays detailed information about files and directories.

Example: exa -l

Output:

drwxr-xr-x  user  group  4 KB  Jul  1 10:00  Documents
drwxr-xr-x  user  group  4 KB  Jul  1 10:00  Pictures
drwxr-xr-x  user  group  4 KB  Jul  1 10:00  Videos

Shows permissions, owner, group, size, modification date, and name for three directories.

3. Tree View

Syntax: exa --tree

Explanation: Displays files and directories in a tree-like structure.

Example: exa --tree

Output:

.
├── Documents
├── Pictures
└── Videos

Shows the current directory and its three subdirectories in a tree structure.

4. Sort by Size

Syntax: exa -S

Explanation: Sorts files and directories by size.

Example: exa -S

Output:

Videos  Pictures  Documents

Lists three directories sorted by size.

5. Show Hidden Files

Syntax: exa -a

Explanation: Lists all files and directories, including hidden ones.

Example: exa -a

Output:

.hidden  Documents  Pictures  Videos

Displays three directories and one hidden file.

6. Display Git Status

Syntax: exa --git

Explanation: Shows the Git status of files and directories.

Example: exa --git

Output:

.M Documents  ?? Pictures  .D Videos

Displays three items with Git status: modified (M) Documents, untracked (??) Pictures, and deleted (D) Videos.

7. Human-Readable Sizes

Syntax: exa -h

Explanation: Displays file sizes in a human-readable format.

Example: exa -h

Output:

Documents  4 KB  Pictures  10 MB  Videos  1 GB

Lists three directories with sizes in KB, MB, and GB.

8. List with Icons

Syntax: exa --icons

Explanation: Displays icons next to the files.

Example: exa --icons

Output:

📁 Documents  📁 Pictures  🎥 Videos

Shows three items with icons representing folders and videos.

9. Color Scale for Sizes

Syntax: exa --colour-scale

Explanation: Displays file sizes with a color scale.

Example: exa --colour-scale

Output:

Documents (green)  Pictures (yellow)  Videos (red)

Lists three directories with colors representing different size scales.

10. Filter by File Type

Syntax: exa --type=directory

Explanation: Lists only directories.

Example: exa --type=directory

Output:

Documents  Pictures  Videos

Shows only the directories in the current location.

11. Group Directories First

Syntax: exa --group-directories-first

Explanation: Lists directories first, followed by files.

Example: exa --group-directories-first

Output:

Documents  Pictures  Videos  file1.txt  file2.txt

Lists three directories followed by two files.

12. Limit Depth of Recursion

Syntax: exa --level=2 --tree

Explanation: Limits the depth of recursion in tree view to 2 levels.

Example: exa --level=2 --tree

Output:

.
├── Documents
│   └── file1.txt
├── Pictures
└── Videos

Shows the current directory and its subdirectories and files up to 2 levels deep.

More Linux commands:
Directory Operations rmdir · cd · pwd · exa · ls
File Operations cat · cp · dd · less · touch · ln · rename · more · head
File System Operations chown · mkfs · locate
Networking ping · curl · wget · iptables · mtr
Search and Text Processing find · grep · sed · whatis · ripgrep · fd · tldr
System Information and Management env · history · top · who · htop · glances · lsof
User and Session Management screen · su · sudo · open
WebsiteFacebookTwitterInstagramPinterestLinkedInGoogle+YoutubeRedditDribbbleBehanceGithubCodePenWhatsappEmail