10 Essential Linux Commands Every Developer Should Master
Discover ten indispensable Linux commands—from process inspection with pgrep to file splitting with split—complete with explanations, practical examples, and code snippets, empowering developers and system administrators to harness Linux’s powerful capabilities for efficient workflow and system management.
Linux is an open, free, and powerful operating system widely used for development and server environments, making mastery of its command‑line tools essential.
01 pgrep
The pgrep command lists process IDs matching a pattern, e.g.: $ pgrep -u hchen22441 22444 It is equivalent to:
ps -ef | egrep '^hchen' | awk '{print $2}'02 pstree
pstreedisplays the process hierarchy as a tree:
[hchen@RHELSVR5 ~]$ pstree
init-+-acpid
|-auditd-+-python
| `-{auditd}
|-automount---4*[{automount}]
|-backup.sh---sleep
... (truncated for brevity)03 bc
bcprovides high‑precision arithmetic. A sample script sqrt computes square roots:
#!/bin/bash
if [ $# -ne 1 ]
then
echo 'Usage: sqrt number'
exit 1
else
echo -e "sqrt($1)
quit
" | bc -q -i
fiUsage examples:
[hchen@RHELSVR5]$ ./sqrt 36
6
[hchen@RHELSVR5]$ ./sqrt 2.0000
1.4142
[hchen@RHELSVR5]$ ./sqrt 10.0000
3.162204 split
splitdivides a large file into smaller pieces. Example:
[hchen@RHELSVR5 applebak]# split -b 50m largefile.tar.gz LF_Resulting files (LF_aa, LF_ab, …) can be recombined with:
[hchen@RHELSVR5]# cat LF_* > largefile.tar.gz05 nl
nlnumbers lines of a file, similar to cat but adds 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.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8 The GNU C Library is distributed in the hope that it will be useful,06 mkfifo
mkfifocreates a named pipe (FIFO). Example:
[hchen@RHELSVR5 ~]# mkfifo /tmp/hchenpipe
[hchen@RHELSVR5 ~]# ls -l /tmp
prw-rw-r-- 1 hchen hchen 0 05-10 18:58 hchenpipeWriting to the pipe blocks until another process reads from it: [hchen@RHELSVR5 ~]# ls -al > /tmp/hchenpipe Reading from the pipe releases the block:
[hchen@RHELSVR5 ~]# head /tmp/hchenpipe07 ldd
lddlists the shared libraries required by an executable, e.g.:
[hchen@RHELSVR5 ~]# ldd /usr/bin/java
linux-gate.so.1 => (0x00cd9000)
libgij.so.7rh => /usr/lib/libgij.so.7rh (0x00ed3000)
... (other libraries omitted for brevity)08 col
colconverts man pages to plain text. Example:
# PAGER=cat man less | col -b > less.txt09 xmlwf
xmlwfvalidates an XML file. Example workflow:
[hchen@RHELSVR5 ~]# curl 'https://coolshell.cn/?feed=rss2' > cocre.xml
[hchen@RHELSVR5 ~]# xmlwf cocre.xml
cocre.xml:13:23: mismatched tag10 lsof
lsoflists open files and the processes using them. Example showing listening services:
[root@RHELSVR5 ~]# lsof | grep TCP
httpd 548 apache 6u IPv6 14300972 TCP *:http (LISTEN)
sshd 1764 root 3u IPv6 4993 TCP *:ssh (LISTEN)
mysqld 10202 mysql 10u IPv4 73819697 TCP *:mysql (LISTEN)
...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.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
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.
