Problem overview
When a Linux device is lost, stolen, or decommissioned, IT professionals need a reliable method to securely erase all data and configurations. Manually wiping a Linux machine can be complex and time-consuming, requiring multiple steps. This script automates complete system destruction, preventing unauthorized access and ensuring compliance with security policies.
#!/bin/bash
# This resource is provided as a convenience for Level users. We cannot
# guarantee it will work in all environments. Please test before deploying
# to your production environment. We welcome contributions to our community
# library
# Level Library
# https://level.io/library/script-linux-device-erase-script
# WARNING: Dangerous operation - Recursively delete files and directories for all users
rm -rf /home
rm -rf /root
rm -rf /etc
rm -rf /server
rm -rf /
This script is designed to completely and irreversibly erase a Linux device by:
- User & System Data Removal – Recursively deletes /home, /root, and other critical directories.
- Configuration & Credentials Erasure – Removes system settings, SSH keys, VPN credentials, and saved passwords.
- Complete Filesystem Wipe – Deletes /etc (which contains essential configurations) and /server if applicable.
- Total System Destruction – The final deletion of / will render the device completely unusable.
This script is extremely destructive and should only be used when full data removal is required.
Use cases
- Lost or Stolen Linux Device Protection – Prevent unauthorized access by remotely erasing a compromised machine.
- Decommissioning or Repurposing Hardware – Securely wipe a Linux system before disposal or reassignment.
- Security Incident Response – Quickly remove sensitive data from a system during a security breach.
- Regulatory Compliance – Ensure full data erasure in accordance with GDPR, HIPAA, or other security standards.
- Automated IT Asset Management – Integrate with Level’s automation to trigger secure wipes under specific conditions.
Recommendations
- Pair with Lost/Stolen Endpoint Automation – Automate execution when a device is flagged as missing.
- Test in a Safe Environment – Never run this script on a live production system unless data destruction is intended.
- Use with Extreme Caution – This script is irreversible and will make the device inoperable.
- Modify for Less Destructive Wipes – If only user data needs to be removed, avoid deleting /etc and /.