10 Lesser-Known Linux Commands Every Sysadmin Should Master
This article introduces ten useful but often overlooked Linux commands—pgrep, pstree, bc, split, nl, mkfifo, ldd, col, xmlwf, and lsof—explaining their purpose, typical use cases, and providing concrete examples to help system administrators work more efficiently.
1) pgrep
The pgrep command lists process IDs matching a pattern, similar to ps -ef | egrep '^hchen' | awk '{print $2}'.
$ pgrep -u hchen
22441
224442) pstree
pstreedisplays the process hierarchy in a tree format.
[hchen@RHELSVR5 ~]$ pstree
init-+-acpid
|-auditd-+-python
... (truncated tree output) ...3) bc
bcis a high‑precision calculator useful for arithmetic such as square‑root calculations. Example script sqrt:
#!/bin/bash
if [ $# -ne 1 ]
then
echo 'Usage: sqrt number'
exit 1
else
echo -e "sqrt($1)
quit
" | bc -q -i
fiUsage:
[hchen@RHELSVR5]$ ./sqrt 36
6
[hchen@RHELSVR5]$ ./sqrt 2.0000
1.41424) split
splitdivides a large file into smaller pieces.
[hchen@RHELSVR5 applebak]# ls -l largefile.tar.gz
-rw-r--r-- 1 hchen hchen 436774774 04-17 02:00 largefile.tar.gz
[hchen@RHELSVR5 applebak]# split -b 50m largefile.tar.gz LF_
[hchen@RHELSVR5]# ls -l LF_*
-rw-r--r-- 1 hchen hchen 52428800 LF_aa
-rw-r--r-- 1 hchen hchen 52428800 LF_ab
... (other parts) ...Reassemble with:
# cat LF_* > largefile.tar.gz5) nl
nlnumbers the lines of a file, similar to cat but with line numbers.
[hchen@RHELSVR5 include]# nl stdio.h | head -n 10
1 /* Define ISO C stdio on top of C++ iostreams.
2 Copyright (C) 1991,1994-2004,2005,2006 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
...6) mkfifo
mkfifocreates a named pipe.
[hchen@RHELSVR5 ~]# mkfifo /tmp/hchenpipe
[hchen@RHELSVR5 ~]# ls -l /tmp
prw-rw-r-- 1 hchen hchen 0 Apr 5 18:58 hchenpipeWriting to the pipe blocks until another process reads from it:
# ls -al > /tmp/hchenpipe # blocks
# head /tmp/hchenpipe # reads and unblocks7) ldd
lddshows the shared libraries required by an executable.
[hchen@RHELSVR5 ~]# ldd /usr/bin/java
linux-gate.so.1 => (0x00cd9000)
libgij.so.7rh => /usr/lib/libgij.so.7rh (0x00ed3000)
... (other libraries) ...8) col
colconverts man page output to plain text.
# PAGER=cat
# man less | col -b > less.txt9) xmlwf
xmlwfvalidates an XML file.
[hchen@RHELSVR5 ~]# curl 'https://coolshell.cn/?feed=rss2' > cocre.xml
... download output ...
[hchen@RHELSVR5 ~]# xmlwf cocre.xml
cocre.xml:13:23: mismatched tag10) lsof
lsoflists open files; useful for finding which processes are using network ports.
[root@RHELSVR5 ~]# lsof | grep TCP
httpd 548 apache 4u IPv6 14300967 TCP *:http (LISTEN)
sshd 1764 root 3u IPv6 4993 TCP *:ssh (LISTEN)
... (other entries) ...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.
Programmer DD
A tinkering programmer and author of "Spring Cloud Microservices in Action"
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.
