โŒจ๏ธ borowicz.github.io

Shell One-Liners with Quick Search

A practical collection of Bash, Zsh, Linux, Unix, Git, log, and networking snippets.

0 snippets visible
No matching snippets. Try a broader keyword like git, dns, log, or file.
๐Ÿ› ๏ธ General shell

Files, text, logs, system, Git, and terminal tricks

Twenty practical one-liners for daily terminal work. Useful for cleanup, searching, text processing, diagnostics, Git housekeeping, and quick shell shortcuts.

๐Ÿงน Find and delete all empty directories

find . -type d -empty -delete
filescleanupfind

๐Ÿ“ฆ Find the 10 largest files in the current folder

du -ah . | sort -rh | head -n 10
filesdisk usagesorting

๐Ÿ“ Batch rename file extensions, for example from .txt to .md

rename 's/\.txt$/\.md/' *.txt
renamefilesbatch

๐Ÿ’พ Create a quick backup of a file

cp file.txt{,.bak}
backupcopyfiles

๐Ÿ”ข Extract unique lines from a file and count occurrences

sort file.txt | uniq -c | sort -nr
textuniqsorting

๐Ÿชต Follow logs in real time and highlight the word Error

tail -f access.log | grep --color=always "Error"
logstailgrep

๐Ÿงฝ Remove duplicate lines without sorting and preserve order

awk '!visited[$0]++' file.txt
awktextdedupe

๐Ÿ” Replace all occurrences of one phrase with another in many files

sed -i 's/old/new/g' *.txt
sedreplacetext

๐Ÿšช Check which process is using a given port, for example 8080

lsof -i :8080
portprocesssystem

๐Ÿ“Š Show the most frequently used commands from shell history

history | awk '{print $2}' | sort | uniq -c | sort -rn | head -10
historyanalyticsterminal

๐ŸŒ Start a quick HTTP server in the current folder using Python 3

python3 -m http.server 8000
httppythonserver

๐ŸŒ Check your external IP address

curl ifconfig.me
networkipcurl

๐ŸŒฟ Delete all local Git branches except main

git branch | grep -v "main" | xargs git branch -D
gitcleanupbranches

๐Ÿ”Ž Find text in all project files with line numbers

grep -rnE "search_phrase" .
grepsearchproject

๐Ÿ“ฆ Clear the npm cache when node modules start acting suspicious

npm cache clean --force
npmcachenode

๐Ÿง  Re-run the last command with sudo

sudo !!
sudoterminalshortcut

๐Ÿ“„ Save command output to a file and still display it on screen

ls -la | tee list.txt
teeoutputfiles

๐Ÿ—๏ธ Create a whole project folder structure in one shot

mkdir -p project/{src,bin,doc,tests}
mkdirscaffoldproject

๐Ÿ’ฅ Kill a process by name instead of hunting for the PID

pkill -f process_name
processpkillsystem

๐Ÿ” Show file permissions in numeric form, for example 755

stat -c "%a %n" *
permissionsstatfiles
๐ŸŒ Network

Network diagnostics, monitoring, HTTP, DNS, and traffic tools

Twenty focused one-liners for Linux and Unix networking. Handy for checking ports, routes, interfaces, DNS, sniffing traffic, HTTP responses, and remote reachability.

๐Ÿงท Check which TCP and UDP ports are listening, including processes

sudo ss -tulpn
networkportsss

๐ŸŒ Quickly check your external IP address

curl -s https://ifconfig.me
ipcurlnetwork

๐Ÿ›ฐ๏ธ Trace a packet route the modern way with mtr

mtr google.com
routingmtrdiagnostics

๐Ÿงฉ Display all network interfaces in a readable short format

ip -brief address show
interfacesipsystem

๐Ÿšช Test a specific port on a remote server

nc -zv 192.168.1.1 80
portnetcatremote

๐Ÿ“ก Scan your local network for active devices

nmap -sn 192.168.1.0/24
nmapscanlan

๐Ÿงพ Find active IP addresses on the network without using nmap

arp -a
arplandiscovery

๐Ÿงญ Check DNS records such as A, MX, and TXT for a domain

dig google.com ANY +noall +answer
dnsdigdomain

๐Ÿ›ฃ๏ธ Display the routing table

ip route show
routegatewaynetwork

๐Ÿ‘€ Sniff live HTTP headers going through the network

sudo tcpdump -A -s 0 'tcp port 80'
tcpdumptraffichttp

๐Ÿ“ˆ Monitor live traffic on a specific network interface

nload eth0 # or iftop
monitoringnloadiftop

๐Ÿท See how much network traffic each process is using

sudo nethogs
processesbandwidthnethogs

๐Ÿ“ก Check HTTP response headers without downloading the body

curl -I https://google.com
curlhttpheaders

๐Ÿ“‚ Start a quick file server in the current folder on port 8000

python3 -m http.server 8000
httppythonserver

โฌ‡๏ธ Download a file and save it using the original filename

curl -O https://example.com/file.zip
downloadcurlfiles

๐Ÿ”„ Restart a network interface such as eth0

sudo ip link set eth0 down && sudo ip link set eth0 up
interfacerestartnetwork

๐Ÿงผ Flush the DNS cache when using systemd-resolved

sudo resolvectl flush-caches
dnscachesystemd

๐Ÿšฆ Find your default gateway

ip route | grep default
gatewayroutenetwork

๐Ÿ“‰ Display error statistics on network interfaces

netstat -i
interfaceserrorsnetstat

๐Ÿ•ต๏ธ Check who owns an IP address or domain

whois 8.8.8.8
whoisownershipsecurity
โฌ†๏ธ Top ๐Ÿ› ๏ธ General ๐ŸŒ Network