我从来没用过的 5 个 Linux 命令
编者注:这是一篇观点文章,本意是幽默风趣。您是否有一套从未使用过的工具?我们邀请来宾通过enable-sysadmin@redhat.com撰写文章。
我确信所有这些命令在某个时候都有其用途,但无论其用途是什么,在我看来,其用途已被弃用。编程是一项艰苦的工作。它耗时、乏味,而且当出现问题时,可能需要花费数小时或数天才能找到导致一切中断的缺失分号或多余空格。我理解这一点,并向编写了我不使用的这款软件的敬业程序员道歉。
[ 您可能还喜欢:系统管理员故事:回顾一个老派 IT 恶作剧]
但是有些命令、程序、应用程序,无论你想叫它们什么,对我来说都是完全不需要的。我发现了五个这样的命令。我没有花时间去追溯它们的来源,因为那将是一个我无法承受的巨大时间真空。所以,这里是它们的全部荣耀——我发现我从未使用过的系统上的五个命令。它们是按字母顺序排列的。
拱门
该arch
命令返回执行该命令的计算机的体系结构。
$ arch
x86_64
是的,它的作用就是这样。它只是显示您正在使用的系统的架构。这是一条重要的信息吗?如果您认为是,那么除了架构之外,您可能还需要有关系统的更多信息。例如,您可以显示文件/proc/version
。
$ cat /proc/version
Linux version 4.18.0-240.22.1.el8_3.x86_64 (mockbuild@x86-vm-07.build.eng.bos.redhat.com) (gcc version 8.3.1 20191121 (Red Hat 8.3.1-5) (GCC)) #1 SMP Thu Mar 25 14:36:04 EDT 2021
好了。你看到了吗?在内核版本中,你还可以获得难以捉摸的架构值。此外,你还可以获得诸如内核和相关 gcc 版本之类的额外信息。
2. 阿帕网
如果您向命令提供一条有价值的信息,该arpaname
命令将为您提供 ARPA 名称:IP 地址。看看您是否能从arpaname
下面的示例中找出该命令为您解密的神秘模式。
$ arpaname 192.168.0.21
21.0.168.192.IN-ADDR.ARPA
相当可靠的命令,对吧?你想再看一遍吗?
$ arpaname 192.168.10.40
40.10.168.192.IN-ADDR.ARPA
我一直希望每次运行它时都会显示不同的东西,但事实并非如此,而且我在每个系统上运行它至少 40 到 50 次,结果令人失望地一致。
3. bc
The bc
and the somewhat similar dc
command are arbitrary precision calculator languages. I'm not sure why one would ever need a command line calculator but if you ever did, these are not the ones to use. First, bc
is interactive, which is fine but it's kind of pointless to use. Almost everyone, even a long time ago, had handheld calculators at their disposal. The only date I could find in the man pages is 2006, and I think at that time just about everyone had a phone with a calculator on it. Surely, there are easier calculators to use than this.
$ bc
bc 1.07.1
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006, 2008, 2012-2017 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
5+10-3
12
Maybe it would be good for scripting? I can think of easier ways to make calculations in a script using variables, but that's just me. I see no point in bc
. I know a lot of people use bc
but I haven't found love for it yet.
And, seriously, dc
is worse because of the crazy syntax you have to use what's known as reverse Polish notation (RPN), plus a ridiculous --expression="
option. I remember my old HP calculator that used RPN and I hated it. An example of RPN for adding two numbers goes like this: 5 6 +. You enter the operands and then the operators. I still hate it. There's no point to that kind of notation and by logical progression, there's no reason for the dc
command that uses it. Here's an example of what dc
syntax looks like. Enjoy.
$ dc --expression="5 6 + f"
11
The 'f
' in the expression prints the entire stack. Here's the description of what the 'f
' option does from the man page: "Prints the entire contents of the stack without altering anything. This is a good command to use if you are lost or want to figure out what the effect of some command has been." How in the world would you ever get "lost" while using this calculator? It's a complete mystery to me as well. The bigger mystery is why anyone would use this outdated calculator and its politically incorrect notation. Perhaps I'll explore bc
and dc
in more detail at a later time.
4. dumpkeys
The dumpkeys
command is really cool. OK, I lied. It's not at all cool. In 25 years of messing with Linux, I've needed to use dumpkeys
a grand total of zero times. You'd think that a critical command like dumpkeys
would have entered into my line of sight at least once in that length of time—even just out of curiosity, it should have been significant enough for me to test, but it wasn't.
Here's how the man page describes this gem: "dumpkeys writes, to the standard output, the current contents of the keyboard driver's translation tables, in the format specified by keymaps(5).
Using the various options, the format of the output can be controlled, and also other information from the kernel and the programs dumpkeys(1) and loadkeys(1) can be obtained."
OK, so now I understand. I know exactly how to use this for...ummm, give me a second, OK, I'm stumped. I don't know how or why I would ever need to use this command other than to tell you that it's useless but for some strange reason, it exists on my Linux system. Oh, to make it better, you can only execute dumpkeys
from the console. The joys never end with dumpkeys
. I so often work at the console and need to write to standard output the current contents of the keyboard driver's translation tables. I'm not even going to give you a demonstration output for this one because it's too long. Feel free to go to your nearest Linux system's console and type in, dumpkeys
. But, stand back or have someone there to catch you because the output is very special—so special in fact, you might want to redirect it to a file and then print it for display in your cubicle or perhaps turn it into a Zoom background image so that everyone you speak to in a day will be duly impressed. And, because sarcasm isn't always obvious in written form, this entire dumpkeys
section has a hint of sarcasm to it. See if you can find it.
5. uname
To be perfectly honest and transparent, I didn't find uname
to be a useless command right away. But soon after I discovered /proc/version
, back in 1996, I realized that uname
had no value. Here are some high-value uname
usage examples.
$ uname
Linux
$ uname -r
4.18.0-240.22.1.el8_3.x86_64
$ uname -m
x86_64
$ uname -a
Linux server1 4.18.0-240.22.1.el8_3.x86_64 #1 SMP Thu Mar 25 14:36:04 EDT 2021 x86_64 x86_64 x86_64 GNU/Linux
$ cat /proc/version
Linux version 4.18.0-240.22.1.el8_3.x86_64 (mockbuild@x86-vm-07.build.eng.bos.redhat.com) (gcc version 8.3.1 20191121 (Red Hat 8.3.1-5) (GCC)) #1 SMP Thu Mar 25 14:36:04 EDT 2021
I think uname's purpose should be changed to print out the username of the current user or copy the whoami
command to uname
. That seems way more valuable to me. Sometimes I forget who I am. I also forget to look at my prompt.
[ Free online course: Red Hat Enterprise Linux technical overview. ]
Wrap up
I hope you had as much fun reading this article as I had writing it. These five useless commands will now forever be associated with me. I'm also sure the hate mail will come pouring in to tell me how absolutely essential these commands are to all the inhabitants of Clipperton Island. I'm good with that.