xutil.dev
Login

Useful One-Liners

Ready-to-use Linux/Unix one-liner collection. HTTP servers, file transfer, text extraction, advanced find, process analysis, binary data, and network debugging recipes organized by category

56 one-liners

python3 -m http.server 8080

Python3 HTTP server

python3 -m http.server 8080 --bind 127.0.0.1

Bind to specific address

python -m SimpleHTTPServer 8080

Python2 HTTP server

ruby -run -e httpd . -p 8080

Ruby HTTP server

php -S 0.0.0.0:8080

PHP built-in server

npx http-server -p 8080

Node.js HTTP server

busybox httpd -f -p 8080

BusyBox HTTP server

perl -MHTTP::Daemon -e '$d=HTTP::Daemon->new(LocalPort=>8080)||die;print "URL: ",$d->url;while($c=$d->accept){while($r=$c->get_request){$c->send_file_response(".".$r->url->path)}}'

Perl HTTP server

nc -lvnp 4444 < file.txt

Send file with Netcat

nc HOST 4444 > file.txt

Receive file with Netcat

curl -T file.txt http://HOST:8080/

Upload file with curl

curl -O http://HOST:8080/file.txt

Download file with curl

scp file.txt user@host:/path/

Transfer file with SCP

rsync -avz --progress src/ user@host:dest/

Sync with rsync

base64 file.bin | tr -d '\n'

Transfer via Base64 encoding

wget -r -np -nH --cut-dirs=1 http://HOST/dir/

Recursive download with wget

grep -oE '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}' file.txt

Extract email addresses

grep -oE '([0-9]{1,3}\.){3}[0-9]{1,3}' file.txt

Extract IP addresses

grep -oE 'https?://[^ "]+' file.txt

Extract URLs

grep -oE '[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}' file.txt | sort -u

Extract domains

sort file.txt | uniq -c | sort -rn | head -20

Sort by occurrence count

sed '/^$/d' file.txt

Remove blank lines

sed -n '/START/,/END/p' file.txt

Extract between patterns

awk -F',' '{print $1,$3}' file.csv

Extract specific CSV columns

find / -perm -4000 -type f 2>/dev/null

Find SUID files

find / -writable -type d 2>/dev/null

Find writable directories

find / -writable -type f 2>/dev/null

Find writable files

find / -mtime -1 -type f 2>/dev/null

Find files modified in last 24h

find / -size +100M -type f 2>/dev/null

Find files larger than 100MB

find . -empty -type f

Find empty files

find . -name "*.tmp" -type f -delete

Find and delete matching files

find . -name "*.log" -exec grep -l "error" {} \;

Find and execute command

lsof -p PID

Open files by process

lsof -i -P -n | grep LISTEN

Listening ports

lsof -i :8080

Process using a port

ls -la /proc/PID/fd

Process file descriptors

strace -p PID -f -e trace=network

Trace system calls

ps auxf

Display process tree

ps aux --sort=-%mem | head -20

Top memory consumers

ps aux --sort=-%cpu | head -20

Top CPU consumers

xxd file.bin | head -50

Hex dump

xxd -p file.bin

Binary to hex string

xxd -r -p hex.txt file.bin

Hex string to binary

strings -n 8 file.bin

Extract strings from binary

dd if=/dev/sda of=backup.img bs=4M status=progress

Copy disk image

objdump -h binary

Binary section headers

base64 file.bin > file.b64

Base64 encode

base64 -d file.b64 > file.bin

Base64 decode

tcpdump -i eth0 -w capture.pcap

Packet capture

tcpdump -i eth0 'port 80' -A

Capture HTTP traffic

iptables -L -n -v --line-numbers

List firewall rules

ss -tulnp

Listening TCP/UDP ports

curl -o /dev/null -s -w 'DNS: %{time_namelookup}s\nConnect: %{time_connect}s\nTLS: %{time_appconnect}s\nTotal: %{time_total}s\n' https://example.com

curl connection timing

ss -s

Network connection statistics

arp -a

Display ARP table

ip route show

Display routing table