{"id":13469344,"url":"https://github.com/alanzchen/rm-protection","last_synced_at":"2026-03-27T04:25:00.752Z","repository":{"id":45586685,"uuid":"80805628","full_name":"alanzchen/rm-protection","owner":"alanzchen","description":"A safe alternative for \"rm\".","archived":false,"fork":false,"pushed_at":"2018-11-10T01:20:53.000Z","size":21,"stargazers_count":419,"open_issues_count":0,"forks_count":34,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-03-14T04:22:25.810Z","etag":null,"topics":["filesystem","linux","macos","python","rm","unix","utility"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alanzchen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-03T07:07:03.000Z","updated_at":"2025-02-10T12:51:58.000Z","dependencies_parsed_at":"2022-08-26T04:43:35.728Z","dependency_job_id":null,"html_url":"https://github.com/alanzchen/rm-protection","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alanzchen%2Frm-protection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alanzchen%2Frm-protection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alanzchen%2Frm-protection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alanzchen%2Frm-protection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alanzchen","download_url":"https://codeload.github.com/alanzchen/rm-protection/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245604131,"owners_count":20642943,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["filesystem","linux","macos","python","rm","unix","utility"],"created_at":"2024-07-31T15:01:34.957Z","updated_at":"2025-12-13T21:02:28.568Z","avatar_url":"https://github.com/alanzchen.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"![rm-protection logo](https://ooo.0o0.ooo/2017/02/03/58943f1ed88cd.png)\n# rm-protection\n\n![Codacy Badge](https://api.codacy.com/project/badge/Grade/a0e08692cc124bcc8a416284d7e6e41a) ![PyPiversion](https://img.shields.io/pypi/v/rm-protection.svg)  ![Wheel](https://img.shields.io/pypi/format/rm-protection.svg)  ![python version](https://img.shields.io/pypi/pyversions/rm-protection.svg) ![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/alanzchen/rm-protection.svg) [![PyPI Downloads](https://pepy.tech/badge/rm-protection)](https://pepy.tech/project/rm-protection)\n\nA safe alternative for `rm` with minimum difference\n\nPorts: See [#ports](#ports)\n\nWiki: https://github.com/alanzchen/rm-protection/wiki\n\n# What is this?\n `rm-protection` is a safe alternative for removing files. It works exactly the same as `rm` (in fact it passes arguments to `rm` almost untouched). The only difference is that it refuses to proceed if a `.*.rm-protection`  file is found and you failed to answer a question.\n\n# Why are you here?\n\nI watched GitLab engineers trying to recover their production database live on YouTube.\n\nSuddenly an idea struck me: What if `rm` prompted to ask \"Which server are you on?\" or \"Which database are you trying to delete?\"?\n\n![What if GitLab Ops had this...](https://ooo.0o0.ooo/2017/02/05/5896a5a715673.png)\n\nThe disaster could have been avoided.\n\n# Quick Start\n\n1.  Install from PyPi and make an alias for `rm-p` .\n\n     `pip install rm-protection` and optionally, `alias rm=\"rm-p\"` for your daily user and **root** (so that it works for `sudo`).\n\n2.  Protect your files using `protect`. If you want to protect everything inside, `protect -R`.\n\n3.  Happy rm-ing!\n\n# How does it work?\n\n It consists of two utilities: `rm-p` and `protect`. The latter one is to help you protect files.\n\n For example, you have a file called `important_file` and it is `protect`ed by `.important_file.rm-protection`. `rm-p` will recognize that `important_file` is protected and prompt to ask you a question stored in `.important_file.rm-protection`. `rm-p` will only proceed if you get the answer right.\n\n See it in action:\n\n ![Basic usage](https://ooo.0o0.ooo/2017/02/03/58943760b76ed.gif)\n\n It will also prevent you from deleting a directory with `protect`ed file(s) inside.\n\n![Recursive protection](https://ooo.0o0.ooo/2017/02/03/589437603366e.png)\n\n# Requirements\n- Python 2 or 3\n- Linux, unix and macOS\n- `find`\n\n# Comparison with alternative methods\n| Methods                                  | Can be used as \"rm\"? | Protect Specific Files | Flexibility | Additional Files   |\n| ---------------------------------------- | -------------------- | ---------------------- | ----------- | ------------------ |\n| [trash-cli](https://github.com/sindresorhus/trash-cli) | Yes                  | Somehow                | High        | Centralised Config |\n| rm -i                                    | Yes                  | No or Somehow          | High        |                    |\n| [safe-rm](https://launchpad.net/safe-rm) | Yes                  | Yes                    | Low         | Centralized Config |\n| rm-protection                            | Yes                  | Yes                    | High        | One for each       |\n\n# Why don't you just use XXX?\n\n `rm-protection` aims at providing maximum protection and flexibility while making minimum impact on daily operation.\n\n `rm -i` can be very annoying, `trash-cli` is a bit complex (imagine you have a habit of emptying the trash without a second thought, or imagine you are trying to free up spaces on a budget vm). ` Safe-rm` is inconvenient when you really need to delete something (you have to edit the configuration file).\n\n Instead, `rm-protection` asks you a question set by you. You are fully covered when removing files (you won't accidentally empty the trash with `trash-cli` or `| yes` with `rm -i`), and you can quickly remove files (without editing any configuration files).\n\n# How to contribute?\nPull requests and issues are all welcome! Or tell others about this, so you can even `protect` the files you send to others!\n\nActually I don't care if people are using my implementation at all. I just think this kind of mechanism can be great -- using a `.rm-protection` file that asks questions.\n\nIf the community welcomes this mechanism, it will soon be ported/rewritten in every platform or languages, or even be implemented in the GNU coreutils. Then you can even get some default protections shipped with distributions and packages.\n\n**So if you agree on this mechanism, please share with others!**\n\n# Ports\n\n## C\n\n- [rm-protection-c](https://github.com/losfair/rm-protection-c)\n  `rm-protection` implemented in C by [losfair](https://github.com/losfair/)\n\n  Current only offers binaries for Linux, source code available for building in macOS and unix.\n\n  (Note that it may behave slightly differently from `rm-protection` and it has not been tested by me.)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falanzchen%2Frm-protection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falanzchen%2Frm-protection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falanzchen%2Frm-protection/lists"}