This is your command line on lsd
Command Line – lsd
A revamp of ls, lsd offers color coding plus revised options relevant to the modern computer.
If you work at the command line, you probably use ls
[1] frequently to list directories and their contents. However, it is one of the oldest commands, and many of its options are no longer relevant to modern computer use. In fact, most people can get by with only a small sub-set of its available options. One of several new revamps, lsd
(LSDeluxe) [2] (Figure 1) attempts to modernize and simplify ls
by assuming a default color code and – apparently – by reducing the number of options and adding options of its own. However, since this is 0.2.21 release, it is hard to be sure exactly what the general release will look like.
The lsd
release page includes Linux packages for Debian and Gentoo. An alternative is to build from source with the Rust Cargo package manager or install a Snap package. Should you install from source, you will also need to install Nerd Fonts [3] in order to use fancy icons to identify file types.
On installation – or perhaps later, after you have tried lsd
and have a better sense of what it can do – you may also want to add a configuration file (Figure 2), copying and modifying the sample provided on the project page. This configuration file should be placed in ~/.config/lsd/config.yaml
. Table 1 lists the main fields available and their settings. Default configurations can be overridden from the command line but can reduce the length of entered commands.
Table 1
Selected Configuration Settings
Field | Description | Values | Default |
---|---|---|---|
|
Sets backward compatibility with |
|
|
|
Specifies the columns and their order |
|
|
|
When to colorize |
|
|
|
Date format for |
|
|
|
Whether to dereference symbolic links |
|
|
|
What items to display |
|
|
|
When to use icons |
|
|
|
Which icon theme to use |
|
|
|
How the icon is separated from the file name |
|
Single space |
|
Which layout to use |
|
|
|
Whether to enable recursion |
|
|
|
The recursion depth |
Any positive number |
|
|
The format of the |
|
|
|
Specify what to sort by |
|
|
|
Whether to reverse the sorting |
|
|
|
Whether to group directories and where |
|
|
Note that in the current release the set colors cannot be altered, although that may change in later releases. Figure 3 shows the default colors currently in use. Colors are only the most obvious ways that directories and files can be coded, the others being --icons
and --icon-themes
(Figure 4) and --classify
(-F
), which uses special characters (*, /, =, >, @, and |) to indicate file types. Probably, most users will want to use only one of these choices.
Options
The current ls
command has 58 options. By contrast, the current lsd
release has 25. More might be added before the general release, but lsd
is already a functional match for ls
and broadly backwardly compatible with it, with much of the same structural logic. However, some of the ls
options are less relevant than they once were. For instance, today only a few applications like Bluefish use ~
to indicate a backup file, so the ls
option --ignore-backups
(-B
) is unlikely to be missed. Similarly, the decline of Emac's popularity means that the --dired
(-D
) option to generate output for Emac's Dired mode seems no longer necessary or at least a low priority to implement. Nor does lsd
require the -C
option for displaying in columns – because it does so by default and other options such as tree or single-line displays are folded into the same command. The overall result is that lsd
is easier to learn than ls
, especially when more than basic options are used.
So what options are left? First, the options that can be placed in a configuration file (Figure 2). They take the same possible values as in the configuration file and override the file as well. Another set of options are those found in ls
. In particular, --all
(-a
) displays dot
files, and --nosymlink
does not display symbolic links, while -directly-only
(-d
) lists only directories. The same sorting options are also used: --recursive
(-r
), --reverse
(-r
), --sizesort
(-s
), and --timesort
(-t
), all of which are self-explanatory. Other options include --total-size
, which displays the total size of directories, and --oneline
(-1
) and --tree
, which offer alternative displays (Figure 5 and 6). And if you have no wish for color or icon coding, you can use --classic
to suppress them. If you are proficient with ls
, many of these options will be familiar.
Naturally, which options you require depends on your current tasks, but you are likely to develop preferences in layout. When you do, consider creating an alias for lsd
so that you have no need to break the habit of typing ls
. To give the simplest alias, in your ~/.bashrc
file or its equivalent, add the line:
<C>alias ls='lsd'<C>
You may want to set other aliases for lsd
, each with its own set of options.
Other ls Updates
In addition to lsd
, at least five more revisions of ls
are competing for the same niche: exa
, colorls
, ls++
, ls-go
, and k
. Many of these are released under an MIT license, and most focus on a color display. However, lsd
is an ideal place to begin exploring the new alternatives. Backwards compatibility makes it an obvious replacement for ls
. While various forms of file coding may be too complex for some users, lsd
offers several choices. However, if lsd
is not for you, you have others to fall back on. Obviously, the time has come to revamp one of Linux's most basic commands.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Linux Servers Targeted by Akira Ransomware
A group of bad actors who have already extorted $42 million have their sights set on the Linux platform.
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.
-
XZ Gets the All-Clear
The back door xz vulnerability has been officially reverted for Fedora 40 and versions 38 and 39 were never affected.
-
Canonical Collaborates with Qualcomm on New Venture
This new joint effort is geared toward bringing Ubuntu and Ubuntu Core to Qualcomm-powered devices.
-
Kodi 21.0 Open-Source Entertainment Hub Released
After a year of development, the award-winning Kodi cross-platform, media center software is now available with many new additions and improvements.
-
Linux Usage Increases in Two Key Areas
If market share is your thing, you'll be happy to know that Linux is on the rise in two areas that, if they keep climbing, could have serious meaning for Linux's future.
-
Vulnerability Discovered in xz Libraries
An urgent alert for Fedora 40 has been posted and users should pay attention.
-
Canonical Bumps LTS Support to 12 years
If you're worried that your Ubuntu LTS release won't be supported long enough to last, Canonical has a surprise for you in the form of 12 years of security coverage.
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.
-
New Pentesting Distribution to Compete with Kali Linux
SnoopGod is now available for your testing needs