= Replacements for old commands

Linux has a good track record for software support.
There are about 60 commands in man section 1 of Unix 1st edition, and the majority still work today.
Still, progress stops for no one.
Thanks to vast global participation in open source, new commands are frequently developed.
Sometimes a new command gains popularity, usually because it offers new features, or the same features but with consistent maintenance.
Here are 10 old commands that have recently been reinvented.

== 1. Replace man with cheat or tealdeer

The man page is functional, and it works well for what it does.
However, man pages aren't always the most succinct at demonstrating how to use the command you're trying to reference.
If you're looking for something a little more to the point, try https://opensource.com/article/22/6/linux-cheat-command[cheat] or https://opensource.com/article/21/6/tealdeer-linux[tealdeer].

== 2. replace ifconfig with ip

The `ifconfig` command provides information about your network interfaces, whether they're physical or virtual.

[source,bash]
----
$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
  inet 10.1.2.34  netmask 255.255.255.0  broadcast 10.0.1.255
  inet6 fe80::f452:f8e1:7f05:7514  prefixlen 64  
  ether d8:5e:d3:2d:d5:68  txqueuelen 1000  (Ethernet)
  [...]

tun0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1360
  inet 10.2.3.45  netmask 255.255.254.0  destination 10.2.14.15
  inet6 2620:52:4:1109::100e  prefixlen 64  scopeid 0x0<global>
  unspec 00-00-00-00-00-00-00-00-[...]0-00  txqueuelen 500  (UNSPEC)
  [...]
----

The newer `ip` command provides similar information:

[source,bash]
----
$ ip -4 address
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    inet 10.1.2.34/24 brd 10.0.1.255 scope global noprefixroute eth0
4: virbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
5: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1360 qdisc pfifo_fast state UNKNOWN group default qlen 500
    inet 10.2.3.45/23 brd 10.2.15.255 scope global noprefixroute tun0
----

== 3. Replace yum with dnf and apt-get with apt

Package managers tend to be slow to change, and when they do they often work hard to maintain backward compatibility.
Both the `yum` command and the `apt-get` command have had improvements lately.
The changes are usually aliased or designed to work in both their old and new syntax:

[source,bash]
----
$ sudo yum install foo
$ sudo dnf install foo
----

[source,bash]
----
$ sudo apt-get install foo
$ sudo apt install foo
----

== 4. Replace repoquery with dnf

Before there was `dnf` there were a variety of utilities for `yum` to help users get reports on their packaging system configuration.
Most of those extra functions got included by default with `dnf`.
For instance, `repoquery` is a subcommand of `dnf`, and it provides a list of all installed packages:

[source,bash]
----
$ sudo dnf repoquery
----

== 5. Replace pip with pip

The `pip` command is a package manager for Python.
It hasn't been replaced, but the preferred syntax has been updated.
The old command:

[source,bash]
----
$ pip install yamllint
----

The new syntax:

[source,bash]
----
$ python3 -m pip install yamllint
----

== 6. Replace ls with exa

The `ls` command hasn't been replaced.

Rather, it hasn't been replaced _again_.

The `ls` command was originally its own binary application, and it's still available as one.
Eventually, though, the Bash shell included its own `ls` built-in command, which by default overrides any installed `ls` command.

Recently, the `exa` command has been developed as, depending on your preferences, a better `ls`.
Read about it in Sudeshna Sur's https://opensource.com/article/21/3/replace-ls-exa[exa command] article, and then try it for yourself.

== 7. Replace du with dust or ncdu

There's nothing wrong with the `du`, which reports on how much disk space is used on your hard drives.
It does its job well, but to be fair it's pretty minimal.

If you're looking for a little variety, try the https://opensource.com/article/21/8/ncdu-check-free-disk-space-linux[ncdu] command or the https://opensource.com/article/21/6/dust-linux[dust] command.

== 8. Replace cat with bat

The https://opensource.com/article/19/2/getting-started-cat-command[cat command] is, aside from being overused by the best of us, is a simple and direct command.
It reads the contents of any number of files, and outputs it to standard input.

Its output is pretty basic, so if you're looking for something with syntax highlighting and flexible output options, try the https://redhat.com/sysadmin/drop-cat-command-bat[bat] command instead.

Does `bat` also replace the https://opensource.com/article/19/9/tac-command[tac] command?
No, don't worry, for now at least `tac` is safe in its position as the command that outputs a file _in reverse_.
(Unless, that is, you count `sed`.)

== 9. Replace netstat with ss

The `netstat` command has largely been replaced by the `ss` command, although of all the commands on this list it's possibly the most hotly debated.
The `ss` command provides much of the same functionality, but as Jose Vicente Nunez points out in his https://www.redhat.com/sysadmin/deprecated-linux-command-replacements[6 deprecated commands] article, there are gaps and differences in functionality.
Before switching wholesale to `ss`, try it and compare it with how you use `netstat` now.

== 10. Replace find with fd

I use `find` to located files, as an input source for https://www.redhat.com/sysadmin/gnu-parallel[GNU Parallel], and more.
I'm pretty familiar with it, but I have to admit that its syntax is a little clunky.
The `fd` command seeks to improve upon that.
For instance, suppose you're looking for a file called `example`, but you can't remember what file extension you used.
With `find`, the syntax might look something like this:

[source,bash]
----
$ find . -name "*example*"
/home/tux/example.adoc
/home/tux/example.sh
----

With `fd`, the syntax is:

[source,bash]
----
$ fd example
/home/tux/example.adoc
/home/tux/example.sh
----

And suppose you want to https://opensource.com/article/21/3/grep-cheat-sheet[grep] command to search through the results for the phrase "zombie apocalypse".
Using find:

[source,bash]
----
$ find . -name "*example*" -exec grep "zombie apocalypse" {} \;
zombie apocalypse
----

Using `fd` instead:

[source,bash]
----
$ fd txt -x grep zombie
zombie apocalypse
----

Read more about it in Sudeshna Sur's https://opensource.com/article/21/6/fd-linux[fd] article, and then try it for yourself.

== Download the cheat sheet

For even more updates to classic commands, download our LINK-TO-CHEATSHEET[cheat sheet].
