How to Recover Files Deleted by RM Command on Mac

The RM command works great and helps remove files quickly and easily. But what if you accidentally delete something important? One wrong move and those files vanish, skipping the Trash completely. We’ve been there and know how easy it is to make that mistake. We’ve also helped plenty of others recover from it. Let’s talk about how to undo the RM command on Mac, what options you have, and what might be out of reach.

Is It Possible to Undo RM Command on macOS?

The short answer is yes, but it comes with some conditions. Let’s first look at what exactly the RM command was used:

rm command description

RM Command Description Is recovery possible?
rm Deletes specified files without prompts (unless permissions prevent writing and input is a terminal) Yes—Files are unlinked but data remains until overwritten.
rm -d Removes directories as well as other types of files Yes—Data can be recovered if not overwritten.
rm -f Forces deletion without prompts, regardless of permissions Yes—Similar to rm, data remains until overwritten.
rm -i Prompt for confirmation before you delete each file. Yes—Same as rm, but with a confirmation step.
rm -I Prompts once if you delete more than three files Yes—Same as rm, with less intrusive confirmation.
rm -P Has no effect; kept for backward compatibility N/A—Does not affect data recovery.
rm -R or rm -r Recursively deletes files and directories; implies -d Yes—Data can be recovered if not overwritten.
rm -v Display each file as it is deleted. Yes—Same as rm, with additional output.
rm -x When deleting recursively, does not cross mount points Yes—Same as rm, limited to the current filesystem.

As you can see, when you delete files using the rm command, they are unlinked from the filesystem, but the actual data remains on the disk until it’s overwritten by new data. This means recovery is possible with specialized software. But that’s not the whole story. There’s more to consider if you don’t have any backups:

  • What kind of drive was it deleted from? Was it a hard drive? or SSD? This detail matters because of TRIM. TRIM is a feature SSDs use that tells the drive to clear data blocks right after deletion. This makes recovery tough because the space gets wiped almost immediately. With HDDs, the data usually stays until new data overwrites it, which gives you more time to recover.
  • If it’s SSD was it an internal or external SSD? If you deleted files from an SSD connected through a hub to your Mac or MacBook, your chances are higher. If it uses a USB Type-A or Type-C connection, macOS doesn’t send the TRIM command to the SSD at all. Even in some cases with Thunderbolt connections through cheaper hubs, TRIM doesn’t run.
  • What happened after the deletion? Did you write new data to the drive? Saved any new files? Any new data can overwrite deleted data and make recovery impossible.
Important. We always recommend, in cases of accidental deletion, to avoid doing anything with the drive from which files were deleted. This means no new files, no downloads, no activity until you’re ready to start the recovery process.

No Backups? Use a Data Recovery App to Recover Files Deleted with RM on a Mac

Sadly, in our experience, people don’t think about backups until it’s too late. So, we’ll start with data recovery software. We will cover backup methods as well, but we’ll get to that later.

Data recovery apps search the drive’s file system for fragments or records of the deleted data, which still exist until they get overwritten. There are many options to choose from, and you can check out our list of the best data recovery apps available for macOS to find one.

Our go-to tool for recovery is Disk Drill. We’ve used it many times in similar situations, and if there’s still something left to recover, Disk Drill can get it done. Here’s how to use Disk Drill to recover files deleted with the RM command:

  1. Head to the official Disk Drill site and download the app. Install it on a different drive than the one where you deleted the files to avoid overwriting data.Install it on a different drive if possible
  2. Open Disk Drill and pick the drive or partition where the RM command deleted your files. If it’s an external drive, make sure it’s connected.Click on Search for lost data
  3. Click on Search for lost data. Disk Drill will automatically run through Quick Scan (finds recently deleted files using the existing file structure), Deep Scan (looks for file fragments and raw data when the file structure is damaged or missing), and Signature Scan (searches for known file types based on their unique binary signatures).Disk Drill scanning the drive
  4. As Disk Drill runs the scan, you can click Review found items at the top to check out files it’s already identified. You can also click on any of the categories shown in the screenshot—like Pictures, Videos, Audio, Documents, Archives, or Other—to jump straight to those file types. This way, you can start looking for what you need even before the full scan finishes.Preview the recoverable files
  5. Take a look at the list of found files. You’ll see them sorted into subcategories like Existing files, Deleted or lost, and Reconstructed. If there are a lot of files, you can use the search bar at the top to find specific files by name or extension, like .pdf or .jpg.
  6. When you click on a file, you’ll see a preview on the right side. Disk Drill also shows recovery chances for each file, so you’ll know how likely it is to get the file back in good shape.
  7. Finally, once you’ve selected all the files you want, click on the Recover button. Keep in mind that the Basic version of Disk Drill lets you scan and preview files, but to actually recover them, you’ll need to upgrade to the PRO version.

Disk Drill is a powerful tool, and we’ve recovered data from all kinds of situations with it—formatted drives, corrupted SD cards, even iPhones. If any tool can get your files back, it’s Disk Drill. But as we said before, not every situation has a happy ending. If the data’s been overwritten, no app, no matter how high-end, can pull off a miracle. So, it’s important to manage your expectations. Acting quickly boosts your chances, but some cases just aren’t recoverable.

Tip. To avoid problems in the future, use Disk Drill’s data protection features. It comes with tools like Recovery Vault and Guaranteed Recovery, which act as safety nets for your files. Recovery Vault logs file metadata so if something gets deleted, you have a better shot at getting it back with all its details intact. Guaranteed Recovery automatically saves copies of deleted files so they’re easy to restore later.

How to Recover Files Deleted with RM on macOS with Backups

Now, as we promised, let’s cover backup options. macOS comes with Time Machine and iCloud as built-in features. If you set them up beforehand, great—you can easily, so to speak, revert the RM command. Here’s a reminder on how to use these features.

1. Time Machine Backup

If Time Machine was active before the deletion, you can recover your files easily. Just connect your backup drive, click the Time Machine icon in the menu bar, and choose Browse Time Machine Backups. Use the timeline on the right to go to the date when your files were still there, find the deleted files, and click Restore. Time Machine will put them back in their original spot, essentially undoing the RM command.

Use the timeline to browse through backups

Tip. Time Machine also keeps local backups, which it updates every 24 hours. So, even if you don’t have your backup drive handy, you can still recover recent versions of deleted files directly from your Mac.

2. iCloud Backup

Another built-in option is iCloud. Just like Time Machine, iCloud needs to have been set up in advance to help with file recovery. iCloud backs up data across your devices, and lets you restore certain files if they were saved to iCloud Drive or other synced locations. Here are the main locations iCloud typically backs up:

  • iCloud Drive. Files saved here sync automatically across all Apple devices linked to your account, like documents, folders, and any files you’ve added to iCloud Drive.
  • Desktop and Documents folders. If enabled, macOS can back up files from your Desktop and Documents folders to iCloud Drive, which makes them accessible on other devices.
  • Photos and videos. If you use iCloud Photos, all photos and videos sync across devices linked to your iCloud account, so they’re available even if deleted from one device.
  • App Data for iCloud-enabled apps. Some apps store data in iCloud, so settings, files, and app-specific data are accessible on any device where you log in.

If the files you need fall into one of these categories, you may be able to restore them directly from iCloud. How to restore files with iCloud:

  1. Open a browser, go to iCloud.com, and sign in with your Apple ID.
  2. Click on Drive to view your files.iCloud web interface
  3. Look in the Recently Deleted folder on the left sidebar. iCloud keeps deleted files here for up to 30 days, so it’s a good place to find files that were removed.Click Recover
  4. Browse through the list, choose the files you want, and click Recover. iCloud will put the files back in their original spot in iCloud Drive.

Is There Only DIY Options?

The DIY methods we covered here usually provide great results. We’ve seen plenty of people successfully undo the RM command on a Mac with these tools. But if you’re not comfortable doing it yourself, or if the deleted data is too important to risk, you can always go with a professional data recovery service.

These services aren’t cheap, but they have access to advanced equipment and tools that home users just don’t have. They’re equipped to handle tough cases, even if the drive is physically damaged. Just keep in mind, though, that even the pros can’t recover data that’s already been overwritten. Once new data fills that space, recovery is out of reach—even with the best gear.

🛡️ Many reputable data recovery services offer a “no data, no charge” policy. If they can’t recover your data, you won’t pay a dime.

FAQ

Unfortunately, once you use the rm command in Terminal, there’s no built-in way to “revert” or undo the deletion. The rm command permanently deletes files without sending them to the Trash, so the files are immediately marked for overwriting, and macOS doesn’t have a Terminal command to recover them.
Unlike files deleted through Finder, which end up in the Trash, files deleted with the rm command don’t “go” anywhere—they’re permanently erased from the file system right away. The rm command skips the Trash completely, but the actual data itself remains on the drive until it’s overwritten by new data.
The rm -rf command is one of the most powerful delete commands on macOS. It permanently deletes files and folders (files skip the Trash). Once you run rm -rf, the files are marked for overwriting, which makes recovery tough. Here’s what you can try:

  • First up, check for backups. If you’ve set up Time Machine or iCloud, you might be in luck. These tools create regular snapshots of your data, so you can go back to a time before the files were deleted. Think of it as hitting the rewind button on your Mac. If backups are active, this is usually your easiest and quickest way to recover files.
  • Next on the list, try data recovery software. If backups aren’t available, data recovery software like Disk Drill might save the day. This software scans your drive for any traces of deleted files. Just a heads-up: if the data hasn’t been overwritten, tools like Disk Drill can help you get it back. But the longer you wait, the more likely it is that new data has taken over that space.
  • And finally, professional data recovery services. If the files are irreplaceable and you’re not getting anywhere with DIY options, a professional data recovery service could be the answer. They use specialized tools to tackle tough cases.
Jeff Cochin is a distinguished expert in data management, recovery, and warehousing, with over a decade of hands-on experience. His expertise extends to data clouds, failovers, SaaS, and constructing digital marketing strategies for high-growth startups. Notably, he holds comprehensive knowledge of Mac computers, Apple's ecosystem, and iPhone technology, making him a trusted authority in these domains. With nearly five years as a dedicated technical writer, Jeff has become a seasoned researcher and reviewer of new applications and services, particularly those within the Apple and Mac universe. His articles and tutorials, often covering nuances of Mac and iPhone use, have graced the pages of many publications, including Macgasm, OnMac, Applenapps, LAWeekly, and more. They have collectively reached a global audience of millions. Jeff spends a substantial portion of his professional life interfacing with AWS, Docker, Medium.com, freeCodeCamp, and SQL-related technologies, integrating these tools with his profound understanding of Mac systems and software. When he's not immersed in writing, troubleshooting, or scripting for Mac and iPhone environments, or staring at computer screens, Jeff embraces the thrill of outdoor adventures. An enthusiast of biking, kayaking, and hiking, he often seeks new trails to explore alongside his like-minded, outdoors-loving friends.
Scroll to top