How to install and use exa command in linux

How To Install And Use exa Command in Linux

For Linux users, the ls command has been a faithful companion for decades, diligently displaying directory contents. But in a world of vibrant interfaces and intuitive design, the black-and-white output of ls can feel a bit… well, bland. Enter exa command, a modern challenger aiming to revolutionize how we interact with our files.

Imagine a file browser infused with the power of the command line, with intuitive colors, informative details, and Git integration seamlessly woven in. That’s exa command in a nutshell. It’s not just a prettier ls; it’s a thoughtfully designed upgrade that enhances your workflow and makes working with files more enjoyable.

Sponsored

So, let’s dive into the world of exa and explore its colorful potential. We’ll cover its core features, delve into its extensive options, and showcase how it simplifies everyday tasks with real-world examples.


What is Exa?

Exa positions itself as a “modern replacement for ls.” It displays file information in a colorful, user-friendly format, with intuitive defaults and extra features. Think of it as ls on steroids, with a sprinkle of visual flair.

By default, exa is a symphony of visual clarity. Files are color-coded based on their type (executables, symlinks, directories, etc.), making scanning directories a breeze. You can instantly identify important files like scripts or images without relying on file extensions. But exa doesn’t stop at aesthetics. It displays essential information like file size, permissions, and timestamps, offering a concise overview without cluttering the terminal.

Key Features That Set exa Apart

  • Colorful Visuals: exa paints your terminal with a spectrum of colors, effortlessly distinguishing file types, permissions, and Git status.
  • Information Richness: Uncover a wealth of file metadata, including inode numbers, extended attributes, block counts, and access times.
  • Grid View: Align files and directories into a well-structured grid, enhancing readability and organization.
  • Customizable Output: Exercise precise control over what information is displayed and how it’s arranged.
  • Performance Prowess: Experience lightning-fast file listings, even in large directories, thanks to parallel execution.
  • Git Integration: Seamlessly visualize Git status for tracked files, empowering version control workflows.
  • User-Friendly Defaults: Enjoy sensible default settings that cater to common usage patterns.

How To Install exa in linux:

Before we dive into the exa command’s capabilities, let’s ensure that it’s installed on your system. You can install exa using the package manager specific to your distribution. For example,

Method 1: Using Package Managers (Recommended):

Arch Linux:

Bash

sudo pacman -S exa

Debian:

Bash

sudo apt install exa

Fedora:

Bash

sudo dnf install rust-exa

Ubuntu (20.10+):

Bash

sudo apt install exa

Method 2: Using Cargo (If Rust and Cargo are installed):

Bash

cargo install exa

Method 3: Manual Installation:

Step1: Download the binary:

See also  Join the Canonical Data and AI team at Data Innovation Summit 2024

Step 2: Extract the archive:

Bash

tar xzf exa-linux-x86_64.tar.gz

Step 3: Move the exa binary to a directory in your $PATH (e.g., /usr/local/bin).

Bash

sudo mv exa /usr/local/bin/

Step 4 (Man Page (Optional): Download the exa.1 man page and place it in /usr/share/man/man1:

Bash

sudo mv exa.1 /usr/share/man/man1

Step 5: Verification:

Open a terminal and type exa --version. If installed correctly, it should output the version information.

Bash

exa --version

Basics Syntax of exa:

While exa shines with its default settings, it also boasts a powerful set of options for tailoring your experience. Let’s explore some of the most useful ones:

Bash

exa [options] [files or directories]
  • options: These are various flags and parameters that modify the behavior of the exa command.
  • files or directories: These are the files or directories you want exa to operate on. If not specified, exa will list the contents of the current directory.

Common Options:

  • -l (long format): Display extended file information, including permissions, owner, group, size, timestamps, and extended attributes.
  • -a (all files): Show all files, including hidden files (those starting with a dot).
  • -t (tree view): List files in a hierarchical tree structure, visually representing directory relationships.
  • -h (human-readable sizes): Display file sizes in human-readable units (e.g., “10M” instead of “10485760”).
  • -g (group directories): Group directories together, making it easier to scan directory structures.
  • -i (icons): Show icons next to file names based on file types.
  • -s (sort by size): Sort files by size, either in ascending or descending order.
  • -r (reverse sort): Reverse the sorting order of the files.
  • -F (classify): Append symbols to file names to indicate their types (e.g., “/” for directories, “*” for executables).
  • -1 (one file per line): List each file on a separate line.

Most Useful exa Commands With Examples:

1. Listing Formats:

‘exa’ allows you to customize the output format using the ‘-l’ flag. This provides a detailed list view, showing additional information such as permissions, owner, group, size, and modification time.

Bash

exa -l

The output will resemble:

Bash

-rw-r--r-- 1 user user 4096 Jan 1 00:00 file.txt
drwxr-xr-x 2 user user 4096 Jan 1 00:00 directory
lrwxrwxrwx 1 user user    4 Jan 1 00:00 symlink -> file.txt

2. Human-Readable Sizes:

To display file sizes in a human-readable format, use the ‘-h’ option:

Bash

exa -lh

This will show file sizes in kilobytes, megabytes, gigabytes, etc.

Bash

-rw-r--r-- 1 user user 4.0K Jan 1 00:00 file.txt
drwxr-xr-x 2 user user 4.0K Jan 1 00:00 directory
lrwxrwxrwx 1 user user    4 Jan 1 00:00 symlink -> file.txt

3. Tree View:

‘exa’ can display directory structures in a tree view using the ‘-T’ option:

Bash

exa -T

The output will represent the hierarchical structure of the directories.

Bash

.
├── directory
   └── subdirectory
       └── file.txt
├── file.txt
└── symlink -> file.txt

4. Sort and Reverse Order:

The ‘-s’ flag allows sorting files by different criteria, such as size, modification time, or name. For instance, to sort by size in reverse order:

Bash

exa -lsS

Output:

Sponsored
Bash

   4096 Jan 1 00:00 directory
   4096 Jan 1 00:00 symlink -> file.txt
      0 Jan 1 00:00 emptyfile.txt
      0 Jan 1 00:00 emptydirectory
      0 Jan 1 00:00 file.txt

In this example, the files and directories are listed in descending order based on their sizes. The ‘directory’ and ‘symlink’ entries are at the top because they have a size of 4096 bytes, followed by an empty file (’emptyfile.txt’), an empty directory (’emptydirectory’), and finally, ‘file.txt’ with a size of 0 bytes.

5. Color Schemes:

‘exa’ supports various color schemes. Let’s use the ‘-l -C classic’ option to apply the ‘classic’ color scheme:

Bash

exa -l -C classic

Output:

Bash

drwxr-xr-x 2 user user 4096 Jan 1 00:00 directory
-rw-r--r-- 1 user user    0 Jan 1 00:00 emptyfile.txt
drwxr-xr-x 2 user user    0 Jan 1 00:00 emptydirectory
lrwxrwxrwx 1 user user    4 Jan 1 00:00 symlink -> file.txt
-rw-r--r-- 1 user user    0 Jan 1 00:00 file.txt

The ‘classic’ color scheme uses a combination of blue, green, and white for directories, regular files, and symbolic links, respectively. The color-coding enhances the visual representation of different file types.

6. Git Integration:

‘exa’ provides Git status integration with the ‘–git (Git Status)‘ flag. Let’s use it to display Git status information:

Bash

exa --git

Output:

Bash

M  file.txt
?? newfile.txt

In this example, ‘file.txt’ is marked with ‘M,’ indicating that it has been modified. ‘newfile.txt’ is marked with ‘??,’ indicating that it is an untracked file. This feature is beneficial for developers working with Git repositories, providing quick insights into the status of files.

7. Filtering and Searching:

‘exa’ allows you to filter files based on specific criteria. Let’s use the ‘–filter’ flag to display only files with a ‘.txt’ extension:

Bash

exa --filter '*.txt'

Output:

Bash

file.txt
emptyfile.txt
newfile.txt

In this example, the ‘–filter’ option filters and displays only the files with the ‘.txt’ extension. This is useful when you want to focus on specific types of files within a directory.

8. File Permissions:

To display only files that have executable permissions, use the ‘-@’ flag:

Bash

exa -l -@

Output:

Bash

-rwxr-xr-x 1 user user 100 Jan 1 00:00 executable.sh

In this example, the ‘executable.sh’ file is the only one listed, and it has executable permissions, denoted by ‘rwxr-xr-x.’ This option helps identify executable files in a directory.

9. Display Gitignore Rules:

The ‘–git-ignore’ flag allows you to display files ignored by Git:

Output:

Bash

.gitignore
ignoredfile.txt

In this example, ‘ignoredfile.txt’ is listed because it is specified in the ‘.gitignore’ file. This option is useful for confirming that files are being correctly ignored by Git.

10. Customizing Output:

‘exa’ provides the ‘–header’ option to customize the column headers in detailed listing mode:

Bash

exa -l --header "Permissions Size Date Modified Name"

Output:

Bash

Permissions Size Date Modified Name
-rw-r--r--    0 Jan 1 00:00 emptyfile.txt
drwxr-xr-x    0 Jan 1 00:00 emptydirectory
lrwxrwxrwx    4 Jan 1 00:00 symlink -> file.txt
-rw-r--r--    0 Jan 1 00:00 file.txt

In this example, the column headers are customized to display only ‘Permissions,’ ‘Size,’ ‘Date Modified,’ and ‘Name.’ This allows you to tailor the output to show specific information based on your preferences.


Command-Line Options For The exa Command:

General Options:

  • -l--long: Display detailed file information in columns.
  • -T--tree: Show directory contents as a tree.
  • -a--all: Show hidden files.
  • -h--human-readable: Display file sizes in human-readable units.
  • -g--grid: Display files and directories in a grid.
  • -s--sort: Sort files by size, time, or name.
  • -r--reverse: Reverse the sorting order.
  • -t--time: Sort by time (modification time by default).
  • --git: Show Git status icons for tracked files.
  • --icons: Display icons for file types.
  • --all: Show all available file metadata.
  • -1--oneline: Display one entry per line.
  • --header: Add a header row to each column.
  • --color: Control when to use terminal colors (always, automatic, never).
  • --color-scale: Highlight different levels of file sizes with distinct colors.
  • --group-directories-first: Show directories before other files.
  • --time-style: Choose the format for timestamps.
  • --level: Number of directory levels to show in tree view.
  • --recurse-R: Recurse into directories.
  • --no-permissions: Don’t show file permissions.
  • --no-user: Don’t show file owner.
  • --no-group: Don’t show file group.

Long View Options (used with -l):

  • -b--binary: List file sizes with binary prefixes.
  • -B--bytes: List file sizes in bytes, without any prefixes.
  • -g--group: List each file’s group.
  • -H--links: List each file’s number of hard links.
  • -i--inode: List each file’s inode number.
  • -m--modified: Use the modified timestamp field.
  • -S--blocks: List each file’s number of file system blocks.
  • -u--accessed: Use the accessed timestamp field.
  • -U--created: Use the created timestamp field.

Other Options:

  • -1--oneline: Display one entry per line.
  • -x--across: Sort the grid across, rather than downwards.
  • -0--null: Separate entries with NUL characters.
  • -v--version: Show version information.
  • -h--help: Show help message.

‘exa’ stands out as a versatile and user-friendly replacement for the traditional ‘ls’ command in Linux. Its intuitive features, colorful output, and integration with Git make it a valuable tool for both beginners and experienced users. By incorporating ‘exa’ into your daily workflow, you can enhance your file navigation and exploration experience on the Linux command line. Whether you’re a developer, sysadmin, or casual user, ‘exa’ brings a refreshing approach to listing directory contents in the terminal.

Explore More:

Ready to dive deeper into exa’s capabilities? Check out its official documentation for a comprehensive overview of options and features: https://the.exa.website/

Join the exa revolution and experience a more colorful, informative, and efficient way to navigate your Linux filesystem. Your terminal will thank you!

So, what are you waiting for? Give exa a try and see how it elevates your file listing experience. If you run into any questions or want to share your favorite exa configurations, don’t hesitate to drop a comment below! And remember, if you found this article helpful, please consider liking and sharing it with your fellow Linux enthusiasts. Let’s spread the word about this fantastic tool and make the terminal a more vibrant and informative place!

The post How To Install And Use exa Command in Linux appeared first on Linux Tutorial Hub.


Discover more from Ubuntu-Server.com

Subscribe to get the latest posts sent to your email.

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply