Boost Your Linux Productivity: 9 Essential Commands You Might Be Missing
This guide introduces nine powerful yet often overlooked Linux command‑line tools—strace, tcpdump, nc, curl, find, lsof, ss, awk/sed, and screen—explaining their key options, typical use cases, and example invocations to help developers work more efficiently on Linux.
strace
strace tracks system calls made by a program. Basic usage to trace a process: strace -p [test_pid] Or run the program directly: strace ./test Useful options: -f – follow child processes (threads). -C – count occurrences of each system call. -e trace=network – show only network‑related calls. -e trace=open,close,read,write – filter specific calls. -ttt – display timestamps. -s 1024 – increase the maximum string length displayed.
Example: trace all read and write calls of every thread in process 12345, with strings up to 1024 bytes:
strace -s 1024 -f -e trace=read,write -p 12345tcpdump
tcpdump captures network packets. Capture all traffic on interface eth0: sudo tcpdump -i eth0 Common options: -A – print packets in ASCII. -X – print packets in both hex and ASCII. -w file – write raw packets to file (e.g., -w 1.cap). host 11.11.11.11 and port 12345 – filter by host and port.
Example: capture HTTP traffic on port 80 and display it as text:
sudo tcpdump -i any port 80 -Anc (netcat)
nc can create TCP/UDP clients and servers.
TCP server on port 12345: nc -l 127.0.0.1 12345 TCP client connecting to the same address: nc 127.0.0.1 12345 UDP server: nc -ul 127.0.0.1 12345 UDP client: nc -u 127.0.0.1 12345 Unix‑domain socket server: nc -Ul /tmp/1.sock Unix‑domain socket client:
nc -U /tmp/1.sockcurl
curl performs HTTP requests from the terminal.
Simple GET request: curl http://www.baidu.com Important options: -H "Host: xx.xx.xx.xx" – set a custom Host header. -X POST – specify request method; -d "data" adds POST data. -v – verbose output, showing request and response headers. -L – follow redirects. -sSfL – silent, show errors, fail on HTTP errors, follow redirects.
find
find searches for files. Find a file named 1.txt in the current directory tree: find . -name "1.txt" Combine with xargs to search file contents: find . -type f | xargs grep 'abcd' This lists all files containing the string abcd .
lsof
lsof lists open files and sockets. sudo lsof -i :[port] – show which process is using a given port. sudo lsof -p [pid] – list files opened by a specific process. ss ss replaces netstat and is faster because it reads /proc/net directly. ss -t -a – show all TCP sockets. ss -u -a – show all UDP sockets. ss -x src /tmp/a.sock – show processes using a Unix socket. ss -o state established – list all established connections. awk / sed awk processes text by columns; sed processes by lines. Print the first field of a colon‑separated file: <code>awk -F ":" '{print $1}' file</code> Show lines 100‑200 of a file: <code>sed -n '100,200p' log.txt</code> Replace a substring in a file: <code>sed "s/charset=gb2312/charset=UTF-8/g" test</code> screen screen creates detachable terminal sessions, useful when SSH connections drop. screen -S test – start a new session named test . Ctrl‑a d – detach from the session. screen -ls – list existing sessions. screen -r 13333.test – reattach to a specific session. exit – close the current screen session. Note: This article assumes familiarity with common commands such as top , netstat , df , and vmstat . The examples focus on less‑known but practical options; consult each command’s manual for the full feature set.
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.
ITPUB
Official ITPUB account sharing technical insights, community news, and exciting events.
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.
