Ultimate Cheatsheet for Developers

Curated list of useful resources and cheatsheets for web developers

View the Project on GitHub zlatanstajic/ultimate-cheatsheet-for-developers

Linux

Family of open source Unix-like operating systems based on the Linux kernel.

Read more about Linux.

Table of Contents

↩ back to list of cheatsheets

Commands that change system packages, services, swap, or protected files require root privileges; use sudo as needed.

See also: cURL — used for downloading files and apt key management.

Misc

# Switch to superuser in terminal
sudo su

# Get list of all processes for app name
ps -ef | grep [app-name]

# Kill all processes by given name
killall [process_name]

# Kill a port process
fuser -k [port-number]/tcp

# Get all IP addresses of the host
hostname -I

# Clear swap space
swapoff -a && swapon -a

# Runs a sound test with static bouncing back and forth
speaker-test --channels 2 --rate 48000 --device hw:[card],[device]

# Loop command
watch -n [number-of-seconds] [command]

# Show live date and time
watch -n 1 date

# Information about how long system has been running
uptime

⬆ back to top

Useful

# Install & run OS configuration tools
apt install dconf-editor && dconf-editor

# Follow Apache error log live
tail -f /var/log/apache2/error.log

# List of apt sources (Ubuntu 24.04+ uses /etc/apt/sources.list.d/ubuntu.sources)
nano /etc/apt/sources.list

# Go to folder with crash reports
cd /var/crash

# Install & run to list folder tree
apt-get install tree && tree
# Show hidden files in tree as well
tree -a

⬆ back to top

Advanced Package Tool

# Search packages
apt-cache search [package-name]

# Install package
apt install [package-name]

# Remove package
apt remove [package-name]

# Remove package and its configuration files
apt purge [package-name]

# Update package index
apt update

# List upgradable packages
apt list -u

# Upgrade all packages
apt upgrade

# Remove cached package files that can no longer be downloaded
apt autoclean

# Remove unused dependencies
apt autoremove

# Remove repository
add-apt-repository -r ppa:[ppa-to-remove]

# Save an ASCII-armored repository signing key as a binary keyring (apt-key is obsolete)
sudo install -d -m 0755 /etc/apt/keyrings
curl -fsSL [key-url] | sudo gpg --dearmor -o /etc/apt/keyrings/[keyring-name].gpg
sudo chmod 0644 /etc/apt/keyrings/[keyring-name].gpg

⬆ back to top

The keyring must also be referenced by Signed-By: /etc/apt/keyrings/[keyring-name].gpg in the repository’s .sources file (or signed-by= in a .list entry). Saving the key alone does not configure a repository. See the APT sources reference.

Services

# Start a service
systemctl start [service-name]

# Stop a service
systemctl stop [service-name]

# Restart a service
systemctl restart [service-name]

# Reload service configuration without restart
systemctl reload [service-name]

# Show service status
systemctl status [service-name]

# Enable service to start on boot
systemctl enable [service-name]

# Disable service from starting on boot
systemctl disable [service-name]

# List all running services
systemctl list-units --type=service --state=running

# Check which process is listening on a port
ss -tlnp | grep [port-number]

⬆ back to top

Directory

# List current path
pwd

# List directory content
ls

# Enter directory
cd [directory-name]

# Create new directory
mkdir [directory-name]

# Create new directory only if it doesn't exist
mkdir -p [directory-name]

# Copy directory
cp -R [source-directory] [destination-directory]

# Move directory
mv [directory-name] [destination-directory]

# Remove an empty directory
rm -d [directory-name]

# Confirm to remove
rm -i [filename]

# Remove all files with extension
rm -fv *.[extension]

⬆ back to top

File

# Create shortcut
ln -s [destination-file] [destination-shortcut]

# Extract a .tar.bz2 archive (-v verbose, -x extract, -j bzip2, -f file)
tar -vxjf [filename].tar.bz2

# Extract a .tar.gz archive
tar -xzf [filename].tar.gz

# Create a .tar.gz archive from a directory
tar -czf [archive-name].tar.gz [directory]

# Get first 5 lines in a file
head -n 5 [file-path]

# Check if website is opened by reading remote Apache access logs
# Usage: connect to server and follow access log
# Example: ssh -t [server] 'tail -f /var/log/apache2/*-access.log'

# Read file live
tail -f [filename]

# Copy file
cp [source-filename] [location-filename]

# Empty file contents
truncate -s 0 [filename]

# Change file permissions (octal: owner/group/others — 4=read, 2=write, 1=execute)
chmod [permissions] [filename]
# chmod 755 script.sh    → owner: rwx, group: r-x, others: r-x (executable script)
# chmod 644 file.txt     → owner: rw-, group: r--, others: r-- (readable file)
# chmod 600 .env         → owner: rw-, group: ---, others: --- (private file)

# Change file owner
chown [user]:[group] [filename]
# chown www-data:www-data /var/www/html   → set web server ownership
# chown -R $USER:$USER ./project          → recursively take ownership

⬆ back to top

Aliases

# List of aliases
vim ~/.bashrc

# Create alias
alias [alias-name]="[command]"

# Remove alias
unalias [alias-name]

# Force list of aliases to reload in current session
source ~/.bashrc

# List all defined aliases
alias

⬆ back to top

Encode-Decode

# base64 encode without new line
echo -n "example" | base64 -w 0

# base64 decode
echo "ZXhhbXBsZQ==" | base64 -d

# URL encode
python3 -c "import urllib.parse, sys; print(urllib.parse.quote(sys.argv[1]))" "string to encode"

# URL decode
python3 -c "import urllib.parse, sys; print(urllib.parse.unquote(sys.argv[1]))" "string%20to%20decode"

⬆ back to top