当您在Mac(Mac)上删除文件时,您最终只会将其隐藏在Finder中。要删除它并释放相关的磁盘空间,您必须清空Trash。按住 Control 键单击垃圾箱(Trash)图标并选择清空垃圾箱(Empty Trash)选项是最快的方法。
但是,永久删除垃圾箱(Trash)中的内容并不总是那么容易,并且可能会导致错误。因此,如果您遇到任何问题,您可以使用终端(Terminal)快速清空macOS 中的垃圾箱(Trash)。您将在下面找到完整的过程。
使用终端删除(Delete)Mac(Mac Using Terminal)中的垃圾箱(Trash)(macOS El Capitan及更高(Later)版本)
如果您使用运行 macOS 10.11 El Capitan或更高版本的(El Capitan)Mac(例如 Big Sur或Monterey ),您可以使用Terminal快速清空Trash。
1. 打开Launchpad并选择其他(Other)>终端(Terminal)。
2. 键入以下命令:
须藤 rm -r(sudo rm -r)
注意:(Note:)暂时不要运行该命令。
3. 按空格(Space)键一次,在命令末尾添加一个空格。这样做很重要。如果不是,该命令将失败。
4. 打开垃圾箱(Trash)。
5. 按住Command(Command)键的同时选择要删除的文件。如果要删除所有内容,请按Command + A立即突出显示所有文件和文件夹。
6. 将突出显示的文件拖入垃圾箱(Trash)。根据您要删除的项目数量,终端(Terminal)中可能会显示多个文件路径。
7. 按回车(Enter)。
8. 输入您的管理员密码。
9. 按回车(Enter)。终端(Terminal)将从Trash中删除指定的项目。您不会收到确认,因此最好仔细检查。
如果终端(Terminal)无法删除特定文件或文件,添加f(强制)选项将覆盖由权限冲突引起的问题。在步骤2中键入sudo rm -rf。
清空废纸篓(Trash)会永久删除文件(除非您在 Mac 上设置了 Time Machine(set up Time Machine on your Mac))。因此(Hence),如果您希望在每次删除之前确认,您可以使用i(交互式)选项,例如sudo rm -ri。
使用终端删除(Delete)Mac(Mac Using Terminal)中的垃圾箱(Trash)(macOS Yosemite及更早(Earlier)版本)
在运行 macOS 10.10 Yosemite 或更早版本的Mac上,使用终端清空(Terminal)垃圾箱(Trash)相对简单。
1. 打开Launchpad并选择其他(Other)>终端(Terminal)。
2. 键入以下命令:
sudo rm -rf ~/.Trash/*
3. 按回车(Enter)。
4. 输入您的管理员密码。
5. 按回车(Enter)。
删除垃圾箱(Trash)中有问题文件(Delete Problematic Files)的替代方法(Ways)
使用终端(Terminal)删除垃圾箱(Trash)很快。但这也很不方便。如果由于特定文件或文件而无法在 macOS 中使用GUI (图形用户界面)清空(GUI)废纸篓(Trash),请下次运行下面的指针。
单独删除项目(Delete Items Individually)
尝试单独删除任何有问题的文件或文件夹。为此,请打开Trash,按住 Control 键单击有问题的项目,然后选择Delete Immediately。
解锁文件并检查权限(Unlock Files and Check Permissions)
macOS 可能会阻止您删除锁定的文件或文件夹。尝试解锁。为此,请按住 Control 键单击垃圾箱(Trash)中的项目,然后选择Get Info。然后,取消选中Locked(Locked)旁边的框。
当您使用它时,您可能还想向下滚动到“共享和权限(Sharing & Permissions)”部分,并将您的用户帐户的权限(Privilege)设置为“读写” 。(Read & Write)如果您没有管理权限,您可能无法执行此操作。
强制退出相关程序(Force-Quit Relevant Programs)
尝试退出任何可能阻止您永久删除文件或文件夹的程序。您可以通过 Mac 的Dock控制单击程序图标并选择Quit来做到这一点。例如,如果您在删除Pages文稿时遇到问题,请完全退出Pages应用程序。
此外,您可能需要检查相关程序是否卡住。为此,请打开Apple菜单并选择Force-quit。如果程序出现在列表中,请选择该项目并选择强制退出(Force Quit)。以下是在 macOS 中强制退出应用程序的其他方法(other ways to force-quit apps in macOS)。
重新启动你的 Mac(Restart Your Mac)
重新启动Mac还可以帮助解决阻止您清空废纸篓(Trash)的错误、故障和冲突。
只需打开Apple菜单并选择Restart。然后,取消选中重新登录时重新打开窗口(Reopen windows when logging back in)旁边的框,然后选择重新启动(Restart)。
禁用冲突的启动程序(Disable Conflicting Startup Programs)
如果您仍然无法正常清空废纸篓(Trash),您可能有一个与 macOS 一起启动的冲突程序。
要删除它,请打开Apple菜单并选择System Preferences > Users & Groups。然后,在侧边栏上选择您的用户帐户并切换到“登录项目(Login Items)”选项卡。通过选择和删除可能导致特定文件格式问题的任何应用程序来遵循这一点。
以安全模式启动 Mac(Booting your Mac in Safe Mode)还可以帮助您识别导致问题的有问题或粗略的启动程序和扩展。
把垃圾带出去
尽管可以在 macOS 中使用终端清空(Terminal)垃圾箱(Trash),但如果可能的话,最好还是坚持使用图形用户界面。花时间找出阻止您删除 Mac垃圾箱(Trash)中的文件而不是强制删除其内容的原因可能会帮助您避免处理相同的问题。
话虽如此,如果您最终永久删除了以后要恢复的文件和文件夹,请不要忘记使用 Time Machine 恢复丢失的项目(restore the lost items using Time Machine)。
How to Quickly Empty the Trash in macOS Using Terminal
When you delete a file on a Mac, you only end up hiding it in Finder. To remove it and freе up the assоciated disk space, you must empty the Trаsh. Control-clicking the Trash icon and picking the Empty Trash option is the fastest way to do that.
However, permanently getting rid of the contents within the Trash isn’t always that easy and may result in errors. So if you run into any trouble, you can quickly empty the Trash in macOS using Terminal instead. You’ll find the complete procedure below.
Delete the Trash in Mac Using Terminal (macOS El Capitan and Later)
If you use a Mac running macOS 10.11 El Capitan or later (such as Big Sur or Monterey), you can quickly empty the Trash using Terminal.
1. Open the Launchpad and select Other > Terminal.
2. Type the following command:
sudo rm -r
Note: Do not run the command yet.
3. Press the Space key once to add a single space to the end of the command. It’s essential to do that. If not, the command will fail.
4. Open the Trash.
5. Select the files you want to delete while holding down the Command key. If you want to remove everything, press Command + A to highlight all files and folders instantly.
6. Drag the highlighted files into the Trash. Depending on how many items you want to delete, multiple file paths may show up in Terminal.
7. Press Enter.
8. Type in your administrator password.
9. Press Enter. Terminal will delete the specified items from the Trash. You won’t receive a confirmation, so it’s best to double-check.
If Terminal fails to delete a specific file or files, adding the f (force) option will override issues caused by conflicting permissions. Type sudo rm -rf in step 2.
Emptying the Trash permanently deletes the files (unless you’ve set up Time Machine on your Mac). Hence, if you prefer confirmation before deleting each time, you can use the i (interactive) option—e.g., sudo rm -ri.
Delete the Trash in Mac Using Terminal (macOS Yosemite and Earlier)
On a Mac running macOS 10.10 Yosemite or earlier, emptying the Trash using Terminal is relatively uncomplicated.
1. Open the Launchpad and select Other > Terminal.
2. Type the following command:
sudo rm -rf ~/.Trash/*
3. Press Enter.
4. Type in your administrator password.
5. Press Enter.
Alternative Ways to Delete Problematic Files in Trash
Deleting the Trash using Terminal is quick. But it’s also inconvenient. If you can’t empty the Trash using the GUI (graphical user interface) in macOS due to a specific file or files, run through the pointers below the next time.
Delete Items Individually
Try deleting any problematic files or folders individually. To do that, open the Trash, control-click the offending item, and select Delete Immediately.
Unlock Files and Check Permissions
macOS may prevent you from deleting a locked file or folder. Try unlocking it. To do that, control-click the item within the Trash and select Get Info. Then, uncheck the box next to Locked.
While you’re at it, you may also want to scroll down to the Sharing & Permissions section and set Privilege to Read & Write for your user account. You may not be able to do that if you don’t have administrative privileges.
Force-Quit Relevant Programs
Try quitting any programs that might be preventing you from permanently deleting a file or folder. You can do that by control-clicking the program’s icon via the Mac’s Dock and selecting Quit. For example, if you have trouble removing a Pages document, fully exit the Pages app.
Additionally, you might want to check if the relevant program is stuck. To do that, open the Apple menu and select Force-quit. If the program appears within the list, select the item and choose Force Quit. Here are other ways to force-quit apps in macOS.
Restart Your Mac
Restarting your Mac can also help resolve bugs, glitches, and conflicts preventing you from emptying the Trash.
Just open the Apple menu and select Restart. Then, leave the box next to Reopen windows when logging back in unchecked and choose Restart.
Disable Conflicting Startup Programs
If you continue to have trouble emptying the Trash normally, you probably have a conflicting program that boots alongside macOS.
To remove it, open the Apple menu and select System Preferences > Users & Groups. Then, select your user account on the sidebar and switch to the Login Items tab. Follow that by selecting and removing any apps that might cause issues with a specific file format.
Booting your Mac in Safe Mode can also help you identify problematic or sketchy startup programs and extensions that cause issues.
Take Out the Trash
Despite being able to empty the Trash using Terminal in macOS, it’s best to stick to the graphical user interface, if possible. Taking the time to figure out what prevents you from deleting files within Mac’s Trash rather than force-deleting its contents may help you avoid having to deal with the same problem going forward.
That being said, if you end up permanently removing files and folders you later want to recover, don’t forget to restore the lost items using Time Machine.