73 Hidden Linux Commands Every Sysadmin Should Bookmark
This article compiles 73 obscure yet highly practical Linux command‑line tricks, ranging from network checks and process management to file manipulation, version control shortcuts, and system monitoring, providing sysadmins and developers a handy reference to boost productivity and streamline everyday tasks.
If you are already using Linux and know some basic commands, here are 73 lesser‑known but extremely useful commands worth bookmarking.
1. Check if remote port is open for bash: echo >/dev/tcp/8.8.8.8/53 && echo "open" 2. Send a process to background: Ctrl + z 3. Bring a process to foreground: fg 4. Generate a random hexadecimal string of n characters: openssl rand -hex n 5. Execute commands from a file in the current shell: source /home/user/file.name 6. Extract the first 5 characters of a variable: ${variable:0:5} 7. SSH debug mode: ssh -vvv user@ip_address 8. SSH with PEM key: ssh user@ip_address -i key.pem 9. Use wget to mirror a website directory structure locally:
wget -r --no-parent --reject "index.html*" http://hostname/ -P /home/user/dirs10. Create multiple directories at once: mkdir -p /home/user/{test,test1,test2} 11. List the process tree including child processes: ps axwef 12. Create a WAR file: jar -cvf name.war file 13. Test disk write speed:
dd if=/dev/zero of=/tmp/output.img bs=8k count=256k; rm -rf /tmp/output.img14. Test disk read speed: hdparm -Tt /dev/sda 15. Get MD5 hash of a text string: echo -n "text" | md5sum 16. Validate XML format: xmllint --noout file.xml 17. Extract a tar.gz archive into a new directory: tar zxvf package.tar.gz -C new_dir 18. Retrieve HTTP headers with curl: curl -I http://www.example.com 19. Change file or directory timestamp (YYMMDDhhmm): touch -t 0712250000 file 20. Perform FTP download with wget: wget -m ftp://username:password@hostname 21. Generate a random password (example 16 characters):
LANG=c < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-16};echo;22. Quickly backup a file: cp some_file_name{,.bkp} 23. Access a Windows share directory:
smbclient -U "DOMAIN\user" //dc.domain.com/share/test/dir24. Execute a command from history (line 100): !100 25. Extract a zip archive to a directory: unzip package_name.zip -d dir_name 26. Input multiple lines of text (Ctrl‑D to exit): cat > test.txt 27. Create an empty file or truncate an existing one: > test.txt 28. Sync time with Ubuntu NTP server: ntpdate ntp.ubuntu.com 29. Show all listening TCP4 ports:
netstat -lnt4 | awk '{print $4}' | cut -f2 -d: | grep -o '[0-9]*'30. Convert qcow2 image to raw format:
qemu-img convert -f qcow2 -O raw precise-server-cloudimg-amd64-disk1.img precise-server-cloudimg-amd64-disk1.raw31. Repeatedly run a command (default every 2 seconds): watch ps -ef 32. List all users: getent passwd 33. Remount root filesystem as read/write: mount -o remount,rw / 34. Bind‑mount a directory (no symlink): mount --bind /source /destination 35. Dynamically update DNS server records:
nsupdate <<EOF
update add $HOST 86400 A $IP
send
EOF36. Recursively grep through all directories: grep -r "some_text" /path/to/dir 37. List the top 10 largest files:
lsof / | awk '{ if($7 > 1048576) print $7/1048576 "MB " $9 }' | sort -n -u | tail38. Show remaining memory in MB:
free -m | grep cache | awk '/[0-9]/{ print $4" MB" }'39. Open Vim and jump to the end of a file: vim + some_file_name 40. Clone a specific Git branch (master): git clone [email protected]:name/app.git -b master 41. Switch to another Git branch (develop): git checkout develop 42. Delete a Git branch (myfeature): git branch -d myfeature 43. Delete a remote Git branch: git push origin :branchName 44. Push a new branch to the remote server: git push -u origin mynewfeature 45. Print the last cat command from history: !cat:p 46. Re‑run the last cat command from history: !cat 47. Find all empty sub‑directories under /home/user: find /home/user -maxdepth 1 -type d -empty 48. Show lines 50‑60 of test.txt: < test.txt sed -n '50,60p' 49. Execute the last command with sudo (e.g., mkdir /root/test): sudo !! 50. Create a temporary RAM filesystem (ramdisk): mount -t tmpfs tmpfs /tmpram -o size=512m 51. Grep whole words: grep -w "name" test.txt 52. Append text to a file with elevated privileges: echo "some text" | sudo tee -a /path/file 53. List all kill signal names: kill -l 54. Prevent the last session from being recorded in Bash history: kill -9 $$ 55. Scan a network for open ports: nmap -p 8081 172.20.0.0/16 56. Set Git email address: git config --global user.email "[email protected]" 57. Sync with master while preserving unpublished commits: git pull --rebase origin master 58. Move all files containing "txt" in their name to /home/user:
find -iname "*txt*" -exec mv -v {} /home/user \;59. Display two files side by side, line by line: paste test.txt test1.txt 60. Show a progress bar for a file in the shell: pv data.log 61. Send data to a Graphite server using netcat:
echo "hosts.sampleHost 10 `date +%s`" | nc 192.168.200.2 300062. Convert tabs to spaces: expand test.txt > test1.txt 63. Skip Bash history for a command: < space >cmd 64. Return to the previous working directory: cd - 65. Split a large tar.gz into 100 MB pieces and recombine:
split –b 100m /path/to/large/archive /path/to/output/files
cat files* > archive66. Get HTTP status code with curl:
curl -sL -w "%{http_code}
" www.example.com -o /dev/null67. Secure MySQL installation and set root password: /usr/bin/mysql_secure_installation 68. When Ctrl + C does not work, use Ctrl + \: Ctrl + \ 69. Get the owner of a file: stat -c %U file.txt 70. List block devices with filesystem info: lsblk -f 71. Find files whose names end with a space: find . -type f -exec egrep -l " +$" {} \; 72. Find files whose names contain a tab character: find . -type f -exec egrep -l '\t' {} \; 73. Print a horizontal line of 100 characters:
printf '%100s
' | tr ' ' =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.
21CTO
21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.
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.
