(Red Hat's) 5 useless Linux commands
redhat.com
redhat.com
They're a bit more useless if you're running Ubuntu/rhel/fedora on standard desktop hardware, but unix is everywhere. And even on desktop in popular distros on standard architectures, removing arch and uname from distros would probably break a lot of install scripts.
I use bc multiple times every day, and uname -a occasionally.
Edit: And `uname` geeez. All-in-all, not a great article.
It's actually a simple programming language with user defined functions, conditionals, loops, etc.
i.e. `sudo apt install linux-headers-$(uname -r) `
If bc(1) and uname(1) dissapers then I will say RHEL isdefinitely heading straight to Windows land. These 2 commands are used a lot. Need to add a long list of numbers, nothing better than bc(1). Plus much easier to use than the pointy/clicky calculators out there.
There are reasons for the tools to be there. When writing scripts, one often relies on the easiest way of producing information. This is something that the author doesn't understand or ignores.
`uname` is indeed very often used in scripts, which is considerably more convenient than parsing `/proc/version` manually; removing it would very likely break a lot of programs.
I don't know about how frequently `bc` is used in scripts, however, bash does not support floating point operations, so I assume it's the typical first choice.
The article seems to be the equivalent of a tabloid piece, especially considering the author's previous posts¹ ("Cyber Week 2020: 13 ideas for what to buy the sysadmin in your life"). I'm baffled by how Red Hat can employ such writers.
[¹] https://www.redhat.com/sysadmin/users/khess - need to click on "Load More" multiple times.
It really seems like redhat is on the way out.
Here's what happens when I use the article's suggestion for finding out the architecture of my Unix but not Linux system:
$ cat /proc/version
cat: /proc/version: No such file or directory
Using "arch" works: $ arch
i386
Similar for "uname".<lists things that lots of scripts use, which this person probably uses without knowing they've used them e.g. if they ever run ./configure>
Unix philosophy of 'do one thing well' is why things like `arch` exist. And I've used `arch` in plenty of scripts. Same with `uname`.
I'll admit that `arch` was more important during the early days of x64 introduction than now, but anyone who deals with legacy hw or embedded platforms is more likely to see it.
$ uname -r
5.8.0-50-generic
$ arch
x86_64
uname -m works though: $ uname -m
x86_64/proc/ may or may not work. It's not a secret that now we have weird solutions like WSL that is actually a linux from users perspective, but some things are a lie. Like load is just a constant string, because there is no kernel that can calculate it properly.
Or look at the mentioned commands in article, but in WSL: host:~$ (WSL): cat /proc/version Linux version 4.4.0-17763-Microsoft (Microsoft@Microsoft.com) (gcc version 5.4.0 (GCC) ) #1217-Microsoft Mon May 05 16:09:00 PST 2020 host:~$ (WSL): arch x86_64
So it DOES provide additional information. Some commands are not used much but in unix-land I can take a book from 1988 and use most of it successfully even on modern weird distributions and projects that are not exactly Linux. But the author suggests I can "ask the source". Well, I can also edit /etc/passwd or sudoers directly, but I won't.
If this is not sarcasm in that article, I am lost how this got published by redhat.
This article is good bait if I ever seen one.
We'll continue with our RH decoupling in the meantime.
That said it’s definitely worth talking about. Last time I looked into it, Red Hat still ship software using many of those commands in their scripts.
I think the author missed an opportunity to discuss why these tools are still used, their history and where specifically they’re still used.
The reception has been so bad they emergency retitled the blog entry "5 Linux commands I never use"
> Indeed. I'm sad to see that it's gotten to the point where @RedHat allows avowedly ignorant cruft like this to get published. Have you ever thought about portability across releases and operating systems? E.g. /proc is not standardized or universal.
> /proc is universal on Red Hat-based Linux systems. That's my perspective on this. I'm not writing from a perspective of all distributions.
... the article doesn't have the word "Red Hat" or "RHEL" anywhere except the code blocks for output of commands, and uses the generic term "Linux" in the title.
Shame on RedHat for this article.
I know many an engineer and physicist that swear by RPN. I actually used it for a while, and totally see their love for it, but couldn't quite get it to stick in my head.
Wow, decades of experience in being a dolt?
uname is in POSIX. It works all over the place. It's based on the uname library function, also standard.
M1 Mac:
kaz@minimac ~ % uname -a
Darwin minimac 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:06:51 PST 2021; root:xnu-7195.81.3~1/RELEASE_ARM64_T8101 arm64
kaz@minimac ~ % uname -m
arm64
kaz@minimac ~ % cat /proc/version
cat: /proc/version: No such file or directory
arch is useless only because it's not in POSIX; scripts should probably be using uname -m when they want arch.Them -m option is very useful, because if you are after "arm64" there is no way you should be writing shell script code to extract it out of the "uname -a" or /proc/version output.
/proc/version could deceive you, even if you're on Linux. Suppose you're in a chrooted cross-compilation environment, like an ARM QEMU environment on an Intel x86_64 machine. In that sandbox, you want *uname -m" to report arm, not Intel.
But if you mount the /proc filesystem into it, I think it will be the host one kernel one with no translation for /proc/version or other telltale entries.
A script that accesses /proc/version could be hostile to cross-compiling in an emulated chroot.
That's just something that occurs to be due to stuff I have learned since 1996.
Now let's talk bc: one reason that is useful because it has bignum arithmetic. And it is specified by POSIX, which spells out this feature in the very name:
bc - arbitrary-precision arithmetic language
Let's see: 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'.
2 ^ 300
20370359763344860862684456884093781610514683936659362506361404493543\
81299763336706183397376
Shell arithmetic cannot do it. Here is bash: $ echo $((2 ** 3))
8
$ echo $((2 ** 300))
0
GNU Awk can do it today, if its compiled with GNU GMP, and invoked with the -M option. POSIX requires no such thing from awk.When I was taking a number theory course in 1994, I used bc for some of the studying and homework due to the bignum support. Today I'd use Lisp; but that's not a commonly installed utility you can count on to be there in a random Unix-like system.
bc doesn't do rational numbers, but it does scaled arithmetic. This is useful for money.
scale = 2
1.13 + 1.14 + 3.19
5.46
5.46 * 1.12
6.11
It can work in bases other than decimal and has a separate input/processing base (ibase register) and output base.Commands like 'arch' might provide a limited amount of data from a different command. However, to extract just the data from the larger response would then require a string of grep/sed/awk. or call the one command to give you the output you specifically need. This also holds true for the 'uname' section.
Can't pipe the input and output of a handheld calculator.
“The only date I could find in the man pages is 2006”
`bc` was in 6th edition Unix, so 1974 or 1975.
I did use it earlier today, though, because I was already at a terminal, so why go elsewhere?