Anton Tajanlangit
asked on
Cannot empty trash in El Capitan
There are a number of files and folders in my MacBook Pro running El Capitan that can't be emptied because an error message says, "The operation can't be performed because the item [so-and-so] is in use."
Well, they definitely aren't in use, and all applications are closed. A reboot doesn't help. I read that it's a glitch in El Capitan.
Any effective workarounds?
Well, they definitely aren't in use, and all applications are closed. A reboot doesn't help. I read that it's a glitch in El Capitan.
Any effective workarounds?
ASKER
I did your instructions. But the Trash still had the same files in it.
What is my username, by the way? Where do I find it?
What is my username, by the way? Where do I find it?
If you can’t remember your user name, open a Finder window and look for the house icon in the sidebar. The house icon identifies your home folder, which has the same name as your user name.
ASKER
Ah ok. I actually used that username in the Terminal window you asked me to type on. But no result.
By the way, the files in question are in an external drive.
By the way, the files in question are in an external drive.
for me the line would look like this
Chown -R edward.pamias .Trash
Make sure there is a space and its case sensitive.
Chown -R edward.pamias .Trash
Make sure there is a space and its case sensitive.
Chown space -R space edwardpamias space .Trash just typing space so you know where they are.
This is just an example...
This is just an example...
After this you should be able to delete the trash.
ASKER
Yes, there were spaces. Perhaps without them I'd be greeted by an error message...
So you typed each line typed exit, then did you try to delete the trash. This apparently gives you permission to your trash so you can delete it. At least that's what I read.
ASKER
Here is a screenshot...
Terminal-window.jpg
Terminal-window.jpg
Were you able to go to the trash and empty it?
ASKER
After doing this, I went on to my Trash and tried to empty it. No joy. Same error message. There are 16 files and folders there that I want to purge.
ASKER
As I mentioned earlier, I'm running El Capitan. Many say that this is an OS bug. Is it true? I wanted a workaround though...
open Terminal Type cd ~/.Trash and press Return
type sudo rm -R followed by a space (don’t leave out the space character—it’s essential). Don’t press Return yet.
Next, click the Trash icon in your Dock to open a window displaying the contents of the Trash. Select everything in that window and drag it into the Terminal window; this action adds the paths of all those files and folders to the rm(remove) command. Now, press Return and enter your administrator password when prompted. In a moment or two (depending on how much was in your Trash), the Trash icon should return to its empty state.
type sudo rm -R followed by a space (don’t leave out the space character—it’s essential). Don’t press Return yet.
Next, click the Trash icon in your Dock to open a window displaying the contents of the Trash. Select everything in that window and drag it into the Terminal window; this action adds the paths of all those files and folders to the rm(remove) command. Now, press Return and enter your administrator password when prompted. In a moment or two (depending on how much was in your Trash), the Trash icon should return to its empty state.
Try rebooting in safe mode (by booting while holding down the shift key) and see if you can then empty the trash.
ASKER
No joy still. There are many error messages. Some say "No such file or directory," "Input/output error," "Directory not empty." The window is full of text.
I've already rebooted many times.
I've already rebooted many times.
Try Strungs suggestion.
One question, were any of the files on an external drive?
ASKER
Yes, they are all in an external drive. In safe mode external drives are not mounted.
The drives are connected correct? Let's try something else....
Press and hold the mouse button on the Trash icon in the Dock. The context menu for Trash will display.
Press and hold the Option key or the Shift-Option keyboard combination,
Select Empty Trash from the context menu for Trash.
Release the keys pressed and held in step 2.
Press and hold the mouse button on the Trash icon in the Dock. The context menu for Trash will display.
Press and hold the Option key or the Shift-Option keyboard combination,
Select Empty Trash from the context menu for Trash.
Release the keys pressed and held in step 2.
ASKER
Done that just now. Some of the files and folders were trashed, but some remained.
Getting close! :) Looks like we need some major trash surgery here.
Here is another solution that may work but this is a bit extreme. It deletes all file and folders and creates a new trash folder for you...
At the Terminal prompt, type one of the following commands:
If the affected account is: Then type the Terminal command:
Your Admin account: sudo rm -ri ~/.Trash
Another user account: sudo rm -ri /Users/user_name/.Trash
where user_name is the short name of the affected account.
Note that:
There is a single space after each of the terms sudo, rm, and -ri in the command.
Assure you have typed the command exactly as specified before proceeding: typographical errors in this command can have dire consequences, including erasing your hard drive!
4. Press Return.
5. Type your Admin password when prompted, then press Return.
6. Type y for yes in response to the subsequent prompts to delete each file in the trash and finally the affected .Trash folder itself. The prompts are finished when the Terminal prompt returns.
7. If the affected account is your Admin account, log out. If the affected account was another user account that is logged in via Fast User Switching, log out of that account.
8. Log in to the affected account. It will now have a new, working, and empty Trash.
At the Terminal prompt, type one of the following commands:
If the affected account is: Then type the Terminal command:
Your Admin account: sudo rm -ri ~/.Trash
Another user account: sudo rm -ri /Users/user_name/.Trash
where user_name is the short name of the affected account.
Note that:
There is a single space after each of the terms sudo, rm, and -ri in the command.
Assure you have typed the command exactly as specified before proceeding: typographical errors in this command can have dire consequences, including erasing your hard drive!
4. Press Return.
5. Type your Admin password when prompted, then press Return.
6. Type y for yes in response to the subsequent prompts to delete each file in the trash and finally the affected .Trash folder itself. The prompts are finished when the Terminal prompt returns.
7. If the affected account is your Admin account, log out. If the affected account was another user account that is logged in via Fast User Switching, log out of that account.
8. Log in to the affected account. It will now have a new, working, and empty Trash.
What's the name of the external drive? It will be mounted on /Volumes/
sudo cd /Volumes/External_Disk/.Trashes/
There will be a numeric folder in there.
sudo ls
????????
There may be multiple trash folders owned be multiple users if you've allowed other users to have access. You just need to delete your own.
rm -r ???????
or you could just remove all your external disk's trash folder directly.
sudo rm -r /Volumes/External_Disk/.Trashes/*
The above line will remove every user's trash folder.
In safe mode, you'll have to use hdutil to mount the external disk, then you will be able to work with files there.
sudo cd /Volumes/External_Disk/.Trashes/
There will be a numeric folder in there.
sudo ls
????????
There may be multiple trash folders owned be multiple users if you've allowed other users to have access. You just need to delete your own.
rm -r ???????
or you could just remove all your external disk's trash folder directly.
sudo rm -r /Volumes/External_Disk/.Trashes/*
The above line will remove every user's trash folder.
In safe mode, you'll have to use hdutil to mount the external disk, then you will be able to work with files there.
ASKER
Edward, I did exactly as you instructed me. I even copy-pasted the Terminal commands from your message so as not to make any mistake in typing. Everything seemed to happen as expected; I was asked a couple of times to which I responded y each time. Then I logged off, and then logged on again. Lo and behold! The Trash was still there. With the same stubborn files. :(
Serialband, your Terminal command didn't work as well...
Serialband, your Terminal command didn't work as well...
Run Repair Disk using disk utility on the drives in question.
Darn files! Well between all of us we will kill these files.
Try this.... after this if it repairs any issues we can go back to trying to empty trash.
Reboot in single user mode by holding the Command + S during boot. When you see a prompt (should look like root # or something similar), type fsck -f and press Return. This is Mac's built-in filesystem consistency check tool and allows you to find and repair errors with the startup file system. Run this command until you don't see **The volume [volume name] was modified.** or the tool fails three times in a row.
Reboot in single user mode by holding the Command + S during boot. When you see a prompt (should look like root # or something similar), type fsck -f and press Return. This is Mac's built-in filesystem consistency check tool and allows you to find and repair errors with the startup file system. Run this command until you don't see **The volume [volume name] was modified.** or the tool fails three times in a row.
ASKER
I just ran it once, and after a while, out came the line, "the volume Mac OS X appears to be OK." I typed "exit" and the system rebooted.
Remember, we are talking of an external drive here. What next?
Remember, we are talking of an external drive here. What next?
https://itunes.apple.com/ca/app/disk-diag-clean-your-hard/id672206759?mt=12&ign-mpt=uo%3D4
If nothing works, try using this application from the Mac App Store. I've had similar problems before and this application cleaned my trash can perfectly.
This application is not free but I am pretty sure you can request a refund if it doesn't do the job.
If nothing works, try using this application from the Mac App Store. I've had similar problems before and this application cleaned my trash can perfectly.
This application is not free but I am pretty sure you can request a refund if it doesn't do the job.
ASKER
Qian, perhaps... if nothing else works out...
@tangjanlangit - If it said the volume Mac OS X appears to be okay, it sounds like you ran disk utility on your internal drive, unless your external is named "Mac OS X".
In disk utility, make sure you select the external drive and run repair disk.
In disk utility, make sure you select the external drive and run repair disk.
ASKER
HI strung, I ran disk utility. It's now called "First Aid" in El Capitan. There were no errors found in my external disk.
OK... so I came across something else. Does any of the files or folders have special characters?? Try opening the trash renaming the files and folders and then try to empty.
ASKER
Nope, they don't have any special characters. I tried renaming some... even also including their filename extensions, in case they're trying to access an application. Didn't work.
Is it saying they are in use?
ASKER
Yes... to be exact, "The operation can't be completed because the item "[blah-blah]" is in use.
Well I found a free app Super Empty Trash that you can try. See if that will help.
https://www.macupdate.com/app/mac/16727/super-empty-trash
https://www.macupdate.com/app/mac/16727/super-empty-trash
Did you do this as the administrator?
ASKER
Oh, yes! It will not even continue up to this point without administrator rights.
If all else fails, back up the drive and reformat it.
Can you move them out of trash?
ASKER
Edward, nope, I can't. I can only either move it back to its original location or copy it to another location. To move it (and thus delete it from where it came from) is just not doable.
Strung, it's not THAT serious that I need to reformat it. It's just a little irritant for me whenever I try to empty the trash.
Strung, it's not THAT serious that I need to reformat it. It's just a little irritant for me whenever I try to empty the trash.
Maybe you ran the command incorrectly. If there's a space in the file or folder name, you must quote it or escape the space
Put quotes around the entire argument to let it know that the space is included as part of the argument string instead of a separator.
sudo rm -r "/Volumes/My Passport/.Trashes/*"
The backslash(\) before the space tells it that it's part of the argument string.
sudo rm -r /Volumes/My\ Passport/.Trashes/*
Put quotes around the entire argument to let it know that the space is included as part of the argument string instead of a separator.
sudo rm -r "/Volumes/My Passport/.Trashes/*"
The backslash(\) before the space tells it that it's part of the argument string.
sudo rm -r /Volumes/My\ Passport/.Trashes/*
@Serialband do you know the command line to see what process is locking these files?
ASKER
There were no backslashes.
This freeware app: http://www.hamsoftengineering.com/products/wkm/wkm.html should tell you what is locking the file.
ASKER
The application What's Keeping Me looks like a helpful piece of software, but it doesn't seem to work with my El Capitan. Although there are items in my Trash, they don't show inside the software.
Regarding lsof in Terminal, here's a screenshot. As usual, nothing came up.
I dragged the file from my Trash to the Terminal window. The backslashes are the result of that dragging.
Regarding lsof in Terminal, here's a screenshot. As usual, nothing came up.
I dragged the file from my Trash to the Terminal window. The backslashes are the result of that dragging.
The backslashes are needed when there's spaces in the folder or file names. Alternatively, you can put the names in quotes to make it more human readable.
That lsof command tells you that you have that folder open in Finder. You should have no problem deleting it with the command I gave you. Cut & paste one of them and you should be able to delete the trash files on the external disk.
There were no backslashes.Your comment suggests that you did not correctly enter the correct rm command line. Please try to copy and paste the command I've given.
That lsof command tells you that you have that folder open in Finder. You should have no problem deleting it with the command I gave you. Cut & paste one of them and you should be able to delete the trash files on the external disk.
Then try removing the one folder that you do have.
sudo rm -r "/Volumes/My Passport/.Trashes/501"
sudo rm -r "/Volumes/My Passport/.Trashes/501"
Try quitting Finder then empty the trash by right-clicking on the trash icon in the dock.
ASKER
Serialband - I copy-pasted your command. Got a Terminal window full of text. What is notable are three different errors that came up at the end of the lines: either "Directory not empty," "Input/output error," or "No such file or directory."
Strung - How do you quit Finder?
Strung - How do you quit Finder?
To quit Finder, in terminal, type:
killall Finder
Alternatively, you can add a "Quit Finder" item to the Finder menu as follows:
In terminal type:
defaults write com.apple.finder QuitMenuItem -bool YES
and hit return. Then type
killall Finder
and hit return.
When you restart Finder, you will have a Quit Finder item in the Finter Menu:
http://osxdaily.com/2010/02/12/how-to-quit-the-finder/
killall Finder
Alternatively, you can add a "Quit Finder" item to the Finder menu as follows:
In terminal type:
defaults write com.apple.finder QuitMenuItem -bool YES
and hit return. Then type
killall Finder
and hit return.
When you restart Finder, you will have a Quit Finder item in the Finter Menu:
http://osxdaily.com/2010/02/12/how-to-quit-the-finder/
You can also kill Finder from Activity Monitor.
So that suggests that the deletion worked at least part of the way.
Try it with the force option (-f).
sudo rm -rf "/Volumes/My Passport/.Trashes/501"
If you need to force quit the finder, click the Apple Menu icon and select force quit, or just press command option power. You will then be able to select the finder from the list and click relaunch.
Try it with the force option (-f).
sudo rm -rf "/Volumes/My Passport/.Trashes/501"
If you need to force quit the finder, click the Apple Menu icon and select force quit, or just press command option power. You will then be able to select the finder from the list and click relaunch.
ASKER
Thanks for the Quit Finder tip, strung. However in spite of it, the Trash still won't empty.
Serialband - the force option in Terminal still didn't work. Same three errors.
Serialband - the force option in Terminal still didn't work. Same three errors.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes, there are fewer items now compared with when we started. The reduction was due to Edward's suggestion:
"The drives are connected correct? Let's try something else....
Press and hold the mouse button on the Trash icon in the Dock. The context menu for Trash will display.
Press and hold the Option key or the Shift-Option keyboard combination,
Select Empty Trash from the context menu for Trash.
Release the keys pressed and held in step 2."
Some files were indeed purged. But there are still others.
Here's a screenshot of Disk Utility's report on my external drive:
Strange, the file system is "unknown."
"The drives are connected correct? Let's try something else....
Press and hold the mouse button on the Trash icon in the Dock. The context menu for Trash will display.
Press and hold the Option key or the Shift-Option keyboard combination,
Select Empty Trash from the context menu for Trash.
Release the keys pressed and held in step 2."
Some files were indeed purged. But there are still others.
Here's a screenshot of Disk Utility's report on my external drive:
Strange, the file system is "unknown."
It is also shown as not writable, not verifiable and not repairable.
Sounds like it need reformatting, or, alternatively, you might have a bad USB cable.
Sounds like it need reformatting, or, alternatively, you might have a bad USB cable.
P.S. can you check it from another computer?
ASKER
Indeed there must be something wrong with the drive. How can it not be writable when I've been writing on it ever since I bought it. How can there be no available space when Finder tells me there's still 300 GB available.
Is there anything I can do about it aside from having to reformat it?
Is there anything I can do about it aside from having to reformat it?
Try a different USB cable and a different computer.
Hopefully you have a back up of the drive. If not I would do that now.
ASKER
I just changed the USB cable now. Same problem. And unfortunately I don't have access to another computer as of now.
I hope to be able to get another drive to back up my files. In the meantime, what else can I do to save the drive?
I hope to be able to get another drive to back up my files. In the meantime, what else can I do to save the drive?
Do you know what the current format is? Does it show what the format is if you right-click on the drive icon and choose Get Info?
If you have valuable information on the drive, the safest thing to do would be to stop using it until you have a back up.
If you have valuable information on the drive, the safest thing to do would be to stop using it until you have a back up.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Nice.... finally! OK I am going on vacation now. :)
Did that fix the trash bin issue?
ASKER
Yes, my external drive is now empty of trash!
Excellent! Glad to hear! This was a good learning experience for all. I added this to my favorites. :)
ASKER
I figured out the solution based on the extremely helpful inputs of all the contributors.
sudo -s <--- you will be asked for your password
chown -R [your_user_name] .Trash <-- just your username no brackets
chmod -R u+rwx .Trash
chmod -RN .Trash
exit