Linux utilities that every developer should know (printable tooltips included)

WebbyLab
WebbyLab
Apr 16 · 9 min read

Work with files

mv /path/to/source /path/to/destination
cp /path/to/source /path/to/destination_directory
cp -r /path/to/source_directory /path/to/destination_directory
cp /path/to/file1 /path/to/file2 /path/to/destination_directory
rm /path/to/file
rm -rf *.txt
rm -rf /path/to/directory
chown user:group /path/to/file
chown -R user:group /path/to/directory
chmod -R a+rw /path/to/directory
chmod — reference=/path/to/source /path/to/destination

Work with disk drives

mount /dev/sdb1 /mnt/usb -t ext4 -o ro -o noload
umount /mnt/usb
umount -f /mnt/usb
dd if=/path/to/input of=/path/to/output
dd bs=4M if=/path/to/linux.iso of=/dev/sdx

Reading logs

head -n 20 access.log
tail -n 30 error.log
tail -f access.log
less access.log
less -N access.log

File system search

find -name ‘netdata.conf’
find / -name ‘*.conf’
find / -type f -name ‘apache2’
find / -type d -name ‘nginx’
find ~ -size +100M
find ~ -size -100M
find ~ -empty
find ~ -empty -exec rm -rf {} \;
grep ‘Forbidden’ error.log
grep -i ‘forbidden’ error.log
grep -c ‘Forbidden’ error.log
grep -i -A2 ‘forbidden’ error.log
grep -i -B2 ‘forbidden’ error.log
grep -i -C2 ‘forbidden’ error.log
grep -i -r ‘access denied’ ~/.pm2/logs

Dealing with processes

ps aux
ps aux | grep node
ps -e -o pid,args --forest
kill -SIGTERM 8888
kill -9 8888
killall node
pgrep -P 3607
lsof /etc/hosts
lsof -i :80

Running processes in background

ping google.com &
ping goole.com & nmap 192.168.1.* &
jobs -l
%1
screen
screen -d -m ping google.com
screen -ls
screen -R [session id]

System resources utilization

tophtop
iotop
du /path/to/directory
ncdu /path/to/directory

View system information

lsb_release -a
lshw
lscpu
free -h
df -h
lsblk

Deal with the network

curl -I http://google.com
curl -d ‘first_name=John&last_name=Doe’ http://google.com
curl -d ‘{“name”:”John”}’ -H ‘content-type: application/json’ http://google.com
curl -O https://www.google.com/images/branding/googlelogo/2x/googlelogo_light_color_272x92dp.png
tcpdump src 127.0.0.1
tcpdump dst 127.0.0.1 -i eth0
tcpdump --list-interfaces
tcpdump src 127.0.0.1 and dst google.com -n
tcpdump dst google.com and port 80 -A
tcpdump dst google.com and port 443 -n
nmap -sP 217.160.0.201
nmap -sP 192.168.1.*
nmap -O 192.168.1.8
nmap -Pn 192.168.1.8
nmap -F 192.168.1.8
nmap -Pn -p 80,443 192.168.1.8
nmap -p U:53,111,137,T:21–25,80,139,8080 192.168.1.1
nmap -Pn — top-ports 10 192.168.1.8

Other utilities

watch -n0.5 ls -laS
reset
cal -j
cal -j 6 2021
id
whoami
echo Hello | base64
echo “SGVsbG8K” | base64 -d
echo ‘{“status”:1}’ | jqcurl https://opinionated-quotes-api.gigalixirapp.com/v1/quotes | jq

Conclusion


WebbyLab

Written by

WebbyLab

WebbyLab - the company develops complicated, high-load and feature-rich Web-projects.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade