Unlock Hidden Linux Gems: Master fold, column, sg, xxd, pwdx, and write
This guide explores lesser‑known Linux /usr/bin utilities—fold, column, sg, xxd, pwdx, and write—showing how each command works, providing example usages, and explaining practical scenarios where they simplify text formatting, group permission handling, hex dumping, process directory inspection, and inter‑user messaging.
In this article we dive into the hidden corners of /usr/bin, uncovering several useful but often overlooked Linux utilities and demonstrating practical ways to use them.
fold
The fold command wraps input lines to a specified width, either by byte count or by spaces, making it handy for formatting long text streams or enforcing line‑length limits in code or configuration files. echo "12345678" | fold -w 7 The output will be:
1234567
8This is useful for breaking long text streams into manageable chunks or enforcing line‑length constraints.
column
The column utility formats text into aligned columns, effectively creating simple tables directly from the command line. It is easier to remember than constructing equivalent awk scripts.
echo -e "one two three
1 2 3
93139 777777 999999" | column -tThe resulting output is:
one two three
1 2 3
93139 777777 999999This tool quickly turns loosely‑structured data into a readable table, automatically adjusting column widths.
sg
The sg command runs a command with the permissions of a specified group, similar to newgrp but without changing the current shell group.
sg sudo lsAfter execution, the command returns to the original group context. This is handy for testing group permissions or temporarily running a program as another group.
xxd
xxdcreates a hexadecimal dump of a file and can also reverse the process. It is useful for inspecting binary data or generating hex representations. xxd linuxmi Typical output:
00000000: 6c69 6e75 786d 690aYou can also write the dump directly to a file:
xxd linuxmi 93139pwdx
The pwdx utility, part of the classic ps family, reports the current working directory of a running process given its PID.
ps aux | grep cronAssuming the PID is 612, run:
sudo pwdx 612This quickly reveals the directory from which a process believes it is running, a valuable troubleshooting aid.
write
The write command sends a message directly to another logged‑in user's terminal. It dates back to early Unix (Version 6, 1975) and remains a simple way to communicate across sessions. write <username> After invoking, you type the message; it appears instantly on the target user's console. The interaction is one‑way and intrusive, so it should be used judiciously.
Although modern messaging tools exist, write is a historical piece of Unix that can still serve niche purposes.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
