Cheatsheet
commands and tricks for day to day
No matches.
- Delete All Commit History on GitHub
Reset a repository's commit history by creating an orphan branch
git checkout --orphan latest_branch git add -A git commit -am "reset configs" git branch -D main git branch -m main git push -f origin main - Chrome Bookmarks (filter by folder)
Extract URLs from a specific Chrome bookmark folder using jq
cat ~/.config/google-chrome/Default/Bookmarks \ | jq -r '.roots.bookmark_bar.children[] | select(.name == "tree") | .children[] | .url' - Chrome Bookmarks (list all)
List all bookmarks from Chrome's JSON file showing name and URL
cat ~/.config/google-chrome/Default/Bookmarks \ | jq '.roots.bookmark_bar.children[] | {name: .name, url: .url}' - Chrome Bookmarks (list folders)
List all Chrome bookmark folders using jq
cat ~/.config/google-chrome/Default/Bookmarks \ | jq -r '[.. | objects | select(.type == "folder") | .name] | unique | sort | .[]' - Chrome Internals Pages
Useful chrome:// internal pages for debugging DNS, events, and proxy settings
chrome://net-internals/#dns chrome://net-internals/#events chrome://net-internals/#proxy - Chrome Bookmarks MacOS(bookmark bar root)
List all entries from the root of Chrome's bookmarks bar
jq -r '.roots.bookmark_bar.children[]' \ "$HOME/Library/Application Support/Google/Chrome/Default/Bookmarks" - Post-install Docker
Add current user to docker group after installation
sudo usermod -aG docker $USER exec su -l $USER groups $USER docker ps - k6 Load Testing
Basic k6 script with ramp-up, sustained load, and ramp-down stages
import http from 'k6/http'; import { sleep } from 'k6'; export const options = { stages: [ { duration: '10s', target: 100 }, { duration: '30s', target: 100 }, { duration: '10s', target: 0 } ] } export default function () { http.get('http://192.168.68.108:3000'); sleep(1); } - ntfy Send Notification
Send a push notification via ntfy.sh using curl
curl -d "Backup successful" ntfy.sh/mytopic - curl with --resolve
Force curl to resolve a hostname to a specific IP address, bypassing DNS
curl --resolve: : :// : curl --resolve meuservidor.com:8080:192.168.0.100 http://meuservidor.com:8080 curl --resolve google.com:8888:127.0.0.1 https://google.com:8888 - Windows Activation (massgrave)
Activate Windows using the massgrave open-source script
irm https://massgrave.dev/get | iex - View WiFi Passwords
Retrieve saved WiFi passwords on Linux using NetworkManager
ls /etc/NetworkManager/system-connections/ sudo cat /etc/NetworkManager/system-connections/[network-name] nmcli device wifi list sudo nmcli connection show "" --show-secrets - Encrypt / Decrypt File with Password
Use OpenSSL AES-256-CBC with PBKDF2 to encrypt and decrypt files
# Encrypt echo "Este é um arquivo de teste" > original.txt openssl enc -aes-256-cbc -salt -pbkdf2 -in original.txt -out secreto.enc # Decrypt openssl enc -aes-256-cbc -d -salt -pbkdf2 -in secreto.enc # Decrypt from remote URL curl -s https://raw.githubusercontent.com/apolzek/apolzek.github.io/main/secreto.enc \ | openssl enc -aes-256-cbc -d -salt -pbkdf2 - Linux Network Connections
View all saved NetworkManager connection configs
sudo cat /etc/NetworkManager/system-connections/* - Set Network Interface MTU
Lower the MTU on a network interface to avoid packet drops (e.g. on iPhone tethering)
sudo ip link set wlp3s0 mtu 1280 - macOS DNS Commands
Commands for viewing, configuring, and troubleshooting DNS on macOS
# Show current DNS resolver configuration (system-wide) scutil --dns # Display DNS servers currently in use (per interface) networksetup -getdnsservers Wi-Fi # Set custom DNS servers for Wi-Fi (replace with your desired servers) sudo networksetup -setdnsservers Wi-Fi 1.1.1.1 8.8.8.8 # Reset DNS back to automatic (DHCP-provided DNS) sudo networksetup -setdnsservers Wi-Fi empty # Flush DNS cache (modern macOS) sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder # Query DNS resolution for a domain (low-level system resolver test) dig example.com # Alternative DNS lookup tool (simpler output) nslookup example.com # Test which DNS server is resolving a domain dig example.com +short # Show detailed resolver behavior and search domains scutil --dns | grep 'nameserver' # Check current network services (to identify correct interface name) networksetup -listallnetworkservices # View DNS configuration for a specific interface (example: Ethernet) networksetup -getdnsservers Ethernet # Set DNS for Ethernet interface sudo networksetup -setdnsservers Ethernet 9.9.9.9 1.1.1.1 - Ubuntu Linux DNS Commands
Commands for viewing, configuring, and troubleshooting DNS on Ubuntu (systemd-resolved and NetworkManager based systems)
# Show current DNS configuration (systemd-resolved) resolvectl status # Alternative command (older systems) systemd-resolve --status # Show DNS servers currently in use per interface nmcli dev show | grep DNS # Show NetworkManager connection profiles nmcli connection show # Set DNS servers for a specific connection (replace 'Wired connection 1') sudo nmcli connection modify "Wired connection 1" ipv4.dns "1.1.1.1 8.8.8.8" # Ignore DHCP-provided DNS and use manual DNS sudo nmcli connection modify "Wired connection 1" ipv4.ignore-auto-dns yes # Restart connection to apply DNS changes sudo nmcli connection down "Wired connection 1" && sudo nmcli connection up "Wired connection 1" # Flush DNS cache (systemd-resolved) sudo resolvectl flush-caches # Alternative cache restart (forces full reload of resolver) sudo systemctl restart systemd-resolved # Query DNS resolution using system resolver getent hosts example.com # Query DNS records with dig (recommended tool) dig example.com # Query specific DNS record type (A record) dig example.com A # Show trace of DNS resolution path dig example.com +trace # Simple DNS lookup tool (basic output) nslookup example.com # Check /etc/resolv.conf (often symlinked to systemd stub) cat /etc/resolv.conf # Verify if systemd stub resolver is active ls -l /etc/resolv.conf # Temporarily set DNS by editing resolv.conf (not persistent on most modern systems) sudo bash -c 'echo -e "nameserver 1.1.1.1\nnameserver 8.8.8.8" > /etc/resolv.conf' - macOS Clipboard Basic Commands
Minimal commands to copy file content to clipboard and paste it back
# Copy file content to clipboard using pipe cat arquivo.txt | pbcopy # Paste clipboard content in terminal pbpaste - Linux Clipboard (Ubuntu) Equivalent to pbcopy/pbpaste
Setup and commands to copy file content to clipboard and paste it back on Ubuntu using xclip or xsel
# Install clipboard utility (xclip) sudo apt update && sudo apt install -y xclip # Copy file content to clipboard (equivalent to: cat arquivo.txt | pbcopy) cat arquivo.txt | xclip -selection clipboard # Paste clipboard content to terminal (equivalent to pbpaste) xclip -selection clipboard -o # Alternative install (xsel instead of xclip) sudo apt install -y xsel # Copy file content using xsel cat arquivo.txt | xsel --clipboard --input # Paste clipboard content using xsel xsel --clipboard --output # Optional aliases for convenience (add to ~/.bashrc or ~/.zshrc) alias pbcopy='xclip -selection clipboard' alias pbpaste='xclip -selection clipboard -o'