pwd
ls -lah
cd ~/projectsWhere am I, list all with sizes, change directory.
Everyday shell commands for Linux (and mostly macOS). Works in bash and zsh.
27 entries
chmod +x deploy.sh
chmod 644 file.txtMake executable; rw-r--r--.
chown -R www-data:www-data /var/wwwChange owner and group recursively.
sudo !!Re-run the last command with sudo.
find . -name "*.log" -mtime -1Files named *.log changed in the last day.
grep -rn "TODO" src/Search text recursively with line numbers.
which python3
type llWhere a command comes from.
sort names.txt | uniq -c | sort -nrCount duplicate lines, most frequent first.
cut -d, -f2 data.csvSecond comma-separated column.
awk '{print $1}' access.logFirst whitespace-separated field.
sed -i 's/foo/bar/g' file.txtReplace in place (macOS: sed -i '').
wc -l file.txtCount lines.
ps aux | grep node
top # or htopList processes; live monitor.
kill 1234
kill -9 1234
pkill -f "python app.py"Stop by PID (TERM, then KILL); by name.
command &
jobs
fg %1Background a job and bring it back.
df -h
du -sh *
free -hDisk space, folder sizes, memory.
systemctl status nginx
journalctl -u nginx -fService status and logs (systemd).
curl -I https://example.com
curl -s api/url | jq .Headers; fetch JSON and pretty-print.
ss -tulpnListening ports and owning processes.
ping -c 4 example.com
dig example.com +shortReachability; DNS lookup.
ssh user@host
scp file user@host:/tmp/Remote shell; copy a file.
tar -czf site.tar.gz site/
tar -xzf site.tar.gzCreate / extract a gzipped tarball.
zip -r out.zip dir/
unzip out.zipZip files.
Run ss -tulpn | grep :8080 (or lsof -i :8080). The output shows the process name and PID.
Owner can read, write and execute (7); group and others can read and execute (5). It is the usual mode for scripts and directories.
kill sends SIGTERM, which lets the program clean up and exit. kill -9 sends SIGKILL, which ends it immediately with no cleanup; use it only when TERM fails.