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
-
Gnome 47.2 Now Available
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.