Which Linux command or utility is simple, powerful, and surprisingly unknown to many people or used less often?
This could be a command or a piece of software or an application.
For example I’m surprised to find that many people are unaware of Caddy, a very simple web server that can make setting up a reverse proxy incredibly easy.
Another example is fzf. Many people overlook this, a fast command-line fuzzy finder. It’s versatile for searching files, directories, or even shell history with minimal effort.
socat
- connect anything to anythingfor example
socat - tcp-connect:remote-server:12345
socat tcp-listen:12345 -
socat tcp-listen:12345 tcp-connect:remote-server:12345
netstat -tunl
shows all open ports on the machine to help diagnose any firewall issues.I use fuck to fix typos
this just reminds me of
please
which runs the previous command withsudo
sudo !!
Will also run the previous command with sudo, fwiw.
That sounds dangerous. I hope it never tries to fix anything with
rm
You have to confirm any command before it runs, so no more dangerous than baseline rm
If you’d map it to just
f
it’s even more handyYou gain efficiency, but lose fun
That’s fantastic, I can’t wait to go home and install it
Game changer!
ip eg:
# ip a # ip a a 192.168.1.99/24 dev enp160
The first incantation - ip address (you can abbreviate whilst it is unambiguous) gets you a quick report of interfaces, MAC, IPs and so on. The second command assigns another IP address to an interface. Handy for setting up devices which don’t do DHCP out of the box or already have an IP and need a good talking to.
Oh and you can completely set up your IP stack, interfaces and routing etc with it. Throw in nft or iptables (old school these days - sigh!) for filtering and other network packet mangling shenanigans.
grep goes crazy if you know your regex
I can never get grep to work consistently on Mac and Linux. Now, ripgrep OTOH…
That’s because Macs generally use BSD-based command line tools instead of GNU ones. You have to do a lot of Homebrew jiggery-pokery to approximate a GNU environment. Know Your Tools: Linux (GNU) vs. Mac (BSD) Command Line Utilities
Alas, doesn’t fit my purpose since it requires action by the script user. I usually just use perl in those situations
Check out my chapter on GNU grep BRE/ERE for those wanting to learn this regex flavor: https://learnbyexample.github.io/learn_gnugrep_ripgrep/breere-regular-expressions.html (there’s also another chapter for PCRE)
- awk
- the (usually rust-based) coreutils “alternatives” like bat, fd, eza, procs
- trash-put (rm with trash integration. But beware that it also operates on directories by default, which rm only does with -r. There should be an option to change that behavior but there isn’t. Don’t alias rm to this)
- wl-copy/paste (or the older one for X11, ‘xclip’ IIRC. Enables you to do stuff like “cat image.jpg | wl-copy” to copy it to the clipboard. Best alias it to something shorter)
- xdg-open (open the file using your associated program for that file type. Alias to “o” or so)
- pass (awesome password manager, when you have a GPG key pair. Even better in combination with e.g. wofi)
- notify-send (to send GUI notifications from shell scripts)
- ledger (plain-text accounting software. If you use Emacs you should take a look at this as it’s written by an Emacs dev, and has good integration of course)
- nc
- nohup
paste. I don’t think a lot of people know this command, but it can be handy at times
xargs
losetup
it’s useful for dealing with virtual disk images. like a real physical hard disk, but it’s a file on the computer. you can mount it, format it, and write it to a real physical disk.
it’s sometimes used with virtual machines, with iso images, or when preparing a bootable disk.
dust
: better version ofdu
. There’s alsodiskonaut
which is an interactive tool.nmap *your_local_ip_address*
for example
nmap 192.168.1.43/24
will show you what devices are connected to the local network, and what ports are open there. really useful, for example, when you forgot the address of your printer or raspi yet again.you can also use it to understand what ports on your computer are open from an attacker’s perspective, or simply to figure out what services are running (ssh service).
Use
less
for checking contents of files. Many people usecat
all the time, but I don’t like it, because if you do that often, your terminal window quickly gets flooded with stuff, and then you have to scroll up and down if you wanna see a previous output. Withless
, your file opens in a different “frame”, which you can close when you’re done.I’d like to interject for a moment. There is also a tool called bat that is just cat with extra features. It prints out and works just like cat, but when the contents get too big, it works like less. The is syntax highlighting and works with git.
It’s replaced my need for cat and less.
Try bat…
cat <your file> | more
Useless use of cat award!
Man
kde connect
jq?
yq can do both JSON and YAML :)
I use it occasionally but every time I need to do something a tiny bit more complex than “extract field from an object” I have to spend half an hour studying its manual, at which point it’s faster to just write a Python script doing exactly what I need it to do.
Check out https://www.nushell.sh/ I use it for exactly that, i.e. complex extract and convert files
I actually installed it recently out of curiosity, but I’m hesitant about learning its advanced features like that. At least jq is a standalone tool that’s more ubiquitous than nushell, so you can rely on it even in environments that you don’t fully control (e.g. CI like GitHub Actions). And if you use it in some public code/scripts then other people will be more familiar with it too.
Funny how this was one of the first tools I learnt once I “seriously” started my linux journey, lol
https://github.com/johnkerl/miller is like awk, sed, cut, join, and sort for name-indexed data such as CSV, TSV, and tabular JSON