Handy Linux command

“REISUB” (The Safe Reboot)

If your entire computer is frozen and the kills above don’t help, Linux users often use the REISUB sequence to reboot safely without corrupting the hard drive. You hold Alt + SysRq and slowly type:

R (unRaw keyboard)
E (tErminate processes)
I (kIll processes)
S (Sync data to disk)
U (Unmount disks)
B (reBoot)

Memory  Tool
sudo apt install htop

Hard Disk Tool:
sudo apt install baobab

MQTT SERVER:

sudo systemctl stop mosquitto
sudo rm /var/lib/mosquitto/mosquitto.db
sudo systemctl start mosquitto
systemctl status mosquitto //IS it running
tail -f /path/to/logfile // Outputs the last 10 lines of a file and actively monitors it for new entries.

PID

PS AUX //Show all process

KILL
Kill PID number
killall python3
killall chrome

Gemini –yolo //accepts all edits without prompting

Networking:
ss -tulpn // Shows all listening ports and the processes attached to them.

🛠️ The “Oops” Savers
history | grep <keyword>: Searches your terminal history for that complex, 50-character command you typed three days ago but forgot to save.

sudo !!: If you type a command and get a “Permission denied” error, running this will instantly rerun your last command with sudo appended to the front.

 

————————–
Python CACHE DELETE:
# Deletes all __pycache__ directories
find . -type d -name “__pycache__” -exec rm -rf {} +

# Deletes any stray compiled Python files (especially helpful for older Python versions)
find . -type f -name “*.py[co]” -delete

# pip cahse purge
pip cache purge

GIT HUB COMMANDS

git status -sb                        # where am I, what’s uncommitted
git fetch                             # refresh knowledge of GitHub; changes nothing local
git log –oneline HEAD..origin/main   # what’s on main that I don’t have
git log –oneline origin/main..HEAD   # what’s mine that main doesn’t have
git diff HEAD — path/to/file         # what changed in this file, really

The merge itself, plus its undo:

git merge origin/main    # pull main into your branch
git merge –abort        # ← the escape hatch. Puts everything back, any time mid-merge.