Essential Linux Shell Commands Every Developer Should Know
A comprehensive cheat‑sheet of 73 practical Linux shell commands—from checking remote ports and managing processes to manipulating files, networking, Git operations, and system monitoring—provides quick reference for developers and sysadmins who need reliable one‑liners for everyday tasks.
This article compiles a handy reference of frequently used Linux shell commands, organized as concise one‑liners that can be copied and executed directly in a terminal. It covers a wide range of tasks such as network checks, process control, file manipulation, Git workflow, system monitoring, and more.
Network and Port Checks
echo >/dev/tcp/8.8.8.8/53 && echo "open"– Test if a remote TCP port is reachable. ssh -vvv user@ip_address – Enable verbose SSH debugging. ssh user@ip_address -i key.pem – Connect using a PEM key. nmap -p 8081 172.20.0.0/16 – Scan a subnet for open ports. curl -I http://www.example.com – Retrieve HTTP headers. curl -sL -w "%{http_code}\n" www.example.com -o /dev/null – Get only the HTTP status code.
echo "hosts.sampleHost 10 `date +%s`" | nc 192.168.200.2 3000– Send data to a Graphite server via netcat.
Process Management
Ctrl+z– Suspend a running process and move it to the background. fg – Bring the most recent background job to the foreground. ps axwef – Display a detailed process tree. watch ps -ef – Repeatedly run ps -ef to monitor processes. kill -l – List all signal names. kill -9 $$ – Terminate the current shell (useful to skip history entry).
File and Text Operations
openssl rand -hex n– Generate a random hexadecimal string of length n. source /home/user/file.name – Execute commands from a file in the current shell. ${variable:0:5} – Extract the first five characters of a variable.
dd if=/dev/zero of=/tmp/output.img bs=8k count=256k; rm -rf /tmp/output.img– Benchmark disk write speed. hdparm -Tt /dev/sda – Benchmark disk read speed. echo -n "text" | md5sum – Compute the MD5 hash of a string. xmllint --noout file.xml – Validate XML syntax. tar zxvf package.tar.gz -C new_dir – Extract a tar.gz archive into a new directory. unzip package_name.zip -d dir_name – Unzip a file to a specific folder. mkdir -p /home/user/{test,test1,test2} – Create multiple directories in one command. find /home/user -maxdepth 1 -type d -empty – List empty sub‑directories. find -iname "*txt*" -exec mv -v {} /home/user \; – Move all files containing "txt" in their name. paste test.txt test1.txt – Display two files side‑by‑side. expand test.txt > test1.txt – Convert tabs to spaces. printf '%100s\n' | tr ' ' = – Print a line of 100 equal signs.
Git Workflow
git clone [email protected]:name/app.git -b master– Clone a specific branch. git checkout develop – Switch to another branch. git branch -d myfeature – Delete a local branch. git push origin :branchName – Delete a remote branch. git push -u origin mynewfeature – Push a new branch and set upstream. git config --global user.email "[email protected]" – Set global Git email. git pull --rebase origin master – Rebase local commits onto the latest master.
System Utilities
mount -o remount,rw /– Remount root filesystem as read/write. mount --bind /source /destination – Bind‑mount a directory. mount -t tmpfs tmpfs /tmpram -o size=512m – Create a RAM‑disk.
nsupdate <<EOF
update add $HOST 86400 A $IP
send
EOF– Dynamically update DNS records. pv data.log – Show a progress bar while copying data. stat -c %U file.txt – Get the owner of a file. lsblk -f – List block devices with filesystem info. find . -type f -exec egrep -l " +$" {} \; – Find files whose names end with spaces. find . -type f -exec egrep -l $'\t' {} \; – Find files containing tab characters.
split –b 100m /path/to/large/archive /path/to/output/files
cat files* > archive– Split and re‑assemble a large tar.gz.
History and Convenience
!100– Execute command number 100 from history. !cat:p – Print the most recent cat command. !cat – Re‑run the last cat command. sudo !! – Re‑run the previous command with sudo. cd - – Return to the previous working directory. vim + some_file_name – Open Vim and jump to the end of a file.
Miscellaneous
cat > test.txt– Enter multi‑line input (terminate with Ctrl+D). > test.txt – Truncate or create an empty file. echo "some text" | sudo tee -a /path/file – Append text to a file with elevated privileges. grep -r "some_text" /path/to/dir – Recursively search for a string. grep -w "name" test.txt – Search for whole‑word matches.
lsof / | awk '{ if($7 > 1048576) print $7/1048576 "MB " $9 }' | sort -n -u | tail– List the ten largest open files. find . -type f -exec egrep -l " +$" {} \; – Find files with trailing spaces in their names.
This cheat‑sheet serves as a quick‑lookup guide for developers, system administrators, and anyone working with Bash on Linux, enabling them to perform common tasks efficiently without having to search for individual command syntax.
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.
