Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Reasons why the ls command is no longer used on Linux

2025-04-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "the reason why the ls command is no longer used on Linux". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "the reason why the ls command is no longer used on Linux"!

If you use Linux and Unix-like operating systems, you will certainly be familiar with or use the ls command-line utility. It lists information about files or directories. As a decades-old command, ls doesn't provide the modern features you might want, such as Git support, color, and tree view output. This is the meaning of the exa tool, a modern alternative to the Linux ls command.

Exa: a substitute for ls file list command written in Rust language

Like ls, exa is a free and open source command-line utility that lists files. However, exa is light, fast and user-friendly, with more features and better query performance.

If you often involve listing hundreds of files and interacting with them, exa can help you reduce a lot of work by using parallel queries to display output in seconds.

Not only is it a quick query, it also makes it easy to identify file types and metadata, which vary by default depending on the color of the file extension.

Exa vs ls

As shown in the figure above, by default, exa also outputs file sizes that are easy for us to view. Although you need to use the-h or-- human- readable option for the ls command.

In addition, exa comes with built-in tools for tree view output, which you can use in conjunction with file information.

Tree view output

The most interesting feature that distinguishes it from exa and ls is the support for the Git version control system.

If you are in the Git repository and want to see if there have been any file changes or modifications since the last commit without installing Git and using git status, you can use the-git option with exa. It adds a new Git column to the metadata table that contains two characters that describe the staged or unstaged state.

Git integration

How do I install Exa on Ubuntu and other Linux distributions?

Interestingly, exa is a separate binary and no dependencies need to be installed. The only thing you need to install is to download the operating system binaries and place them in the directory listed in the $PATH environment variable (most likely / usr/bin/).

However, if you find this manual method difficult, another (and easiest) way to install exa is to use the system's default package manager.

For Debian and Ubuntu 20.10 cycles, you can run:

Linuxmi@linuxmi:~/www.linuxmi.com$ sudo apt install exa

On Arch Linux

Linuxmi@linuxmi:~/www.linuxmi.com$ pacman-S exa

On Fedora

Linuxmi@linuxmi:~/www.linuxmi.com$ dnf install exa

For Gentoo

Linuxmi@linuxmi:~/www.linuxmi.com$ emerge sys-apps/exa

On openSUSE

Linuxmi@linuxmi:~/www.linuxmi.com$ zypper install exa

On Fedora

Linuxmi@linuxmi:~/www.linuxmi.com$ dnf install exa

Also, if you are using macOS and you have installed the Homebrew package manager, run the following command:

Linuxmi@linuxmi:~/www.linuxmi.com$ brew install exa

Finally, you can also use the source code, the required dependencies, and follow the instructions given here to compile and build.

How to use Exa?

List files with metadata

Using the-- long or-l option, you can display the file and its metadata.

Linuxmi@linuxmi:~/www.linuxmi.com$ exa-l

List metadata

Also, if you don't know what each column in the metadata means, you can use the same option,-- header or-h, to add a new row that defines each column.

Linuxmi@linuxmi:~/www.linuxmi.com$ exa-lh

List file details with header

Display the contents of the directory

If you want to list all the contents of a particular directory, use the current directory path as a parameter, not the current directory.

Linuxmi@linuxmi:~/www.linuxmi.com$ exa / home/linuxmi

List catalogs

List files in all directories and subdirectories

To list directories and subdirectories recursively, you can choose-- recurse or-R. It creates a separate list for each subdirectory.

Linuxmi@linuxmi:~/www.linuxmi.com$ exa-R

Recursive subdirectory

List the contents of the directory in a tree structure

Because exa has a built-in tool to display tree-like content recursively, you don't need additional commands like trees. You can use the-- tree or-T option, which lists the contents of all directories and subdirectories in a tree structure.

Linuxmi@linuxmi:~/www.linuxmi.com$ exa-R

Tree structure output

If you want to view the contents of a subdirectory to a certain extent, you can also use the-L or-- level= (depth) option to limit the depth of recursion.

Linuxmi@linuxmi:~/www.linuxmi.com$ exa-T-L 2

Depth-constrained tree structure output

Linuxmi@linuxmi:~/www.linuxmi.com$ exa-T-L 1

Depth-constrained tree structure output

Disable color output

Don't you like to check the color terminal output? Well, exa also accepts the-- color option, whose values are always, automatic, and never. If you want to disable colors, pass the-- color=never parameter.

Linuxmi@linuxmi:~/www.linuxmi.com$ exa-long-color=never

Disable exa output of colors

If you want to make the most of the exa utility, you can read its official documentation.

Do you think it's time to replace ls with the exa command, or have you done so now? Please tell us in the comments below.

At this point, I believe you have a deeper understanding of "the reason why the ls command is no longer used on Linux". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report