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 | 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.
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:
- 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.
- 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. 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).
- 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.
- 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.
- 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.
- 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.
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.
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:
- Open a browser, go to iCloud.com, and sign in with your Apple ID.
- Click on Drive to view your files.
- 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.
- 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.
FAQ
- 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.