PDA

View Full Version : Terminal: rm ./AppleTV.dmg makes file go where?


turtle
2009-01-24, 00:43
I recently used this command to get rid of an image I started to create as part of my AppleTV HDD upgrade. When my local HDD filled it failed to complete the image. I cleared off the space and threw that image in the trash as well. When I emptied the trash, Finder wouldn't actually remove AppleTV.dmg because it was in use.

So in Terminal I executed the above command but I didn't get my space back. The file isn't in finder but neither is my space where it was. Where did it go? Is there a Terminal command to empty the trash?

Kickaha
2009-01-24, 00:45
It is instantly deleted, no Trash, no recovery, no second chance.

Brad
2009-01-24, 00:47
rm deletes the file directly. It doesn't move it to the Trash like the Finder does.

Do you have File Vault enabled for you account? If so, you'll have to log out (while connected to the power supply) for the system to unmount your home directory and "recover free space".

For further investigation as to where your space has gone, may I suggest Disk Inventory X (http://www.derlien.com/)? :)

turtle
2009-01-24, 00:49
Thanks guys. :confused:

I wonder why I haven't gotten my space back. I do have Disk Inventory X and was about to use it but thought I had better learn more about a command I just used since it didn't seem to do what I thought it would.

Edit: Ok, space is back. Seems my Mini needs a nap. :\ It's having a hard time keeping up with it's disk space. :D

scratt
2009-01-24, 04:13
I don't know about anyone else, but especially when working remotely, the rm commands and similar scare the bejesus out of me!

I tend to do a quick man check each time before I use them!

Kickaha
2009-01-24, 11:44
Thanks guys. :confused:

I wonder why I haven't gotten my space back. I do have Disk Inventory X and was about to use it but thought I had better learn more about a command I just used since it didn't seem to do what I thought it would.

Edit: Ok, space is back. Seems my Mini needs a nap. :\ It's having a hard time keeping up with it's disk space. :D

If you were checking the disk space in the Finder, keep in mind it does *not* always show an immediate update of the free space, particularly when you remove the files at the command line. After some Great CLI Purge, I always go back in the Finder and click on the drive in the sidebar - this boots the Finder in the head to update the value at the bottom of the window.

tomoe
2009-01-24, 11:52
I don't know about anyone else, but especially when working remotely, the rm commands and similar scare the bejesus out of me!

I tend to do a quick man check each time before I use them!

Agreed...that's why I have an alias in my .bashrc file with:

alias rm='rm -iv'

This way I'm prompted before ever removing a file.:)

Brad
2009-01-24, 12:32
If you were checking the disk space in the Finder, keep in mind it does *not* always show an immediate update of the free space, particularly when you remove the files at the command line. After some Great CLI Purge, I always go back in the Finder and click on the drive in the sidebar - this boots the Finder in the head to update the value at the bottom of the window.
Yup. The Finder can definitely be finicky like that.

Alternatively, while you're in the CLI after the Great Purge, fire off a "df -h" to get an always up-to-date view of your disk usage.

turtle
2009-01-24, 21:48
Thanks for the tips guys. I'm sure the delay was our great Finder then. Oh well.

The good part is my Apple TV now has a 250GB drive in it and playing Finding Nemo for my 2 year old. :)

Taskiss
2009-01-24, 22:15
Old school:

sync;sync;sync

curiousuburb
2009-01-25, 06:42
How about a poll?

rm makes file go where:


poof
buh-bye
to bit heaven
to its happy place
beer

ShadowOfGed
2009-01-27, 02:07
Welcome to POSIX! Let's turn this into a filesystems lesson.

I know, I know, I'm being a bit of a wise-ass here. It's because this sounds like a case of POSIX filesystems doing things you may not expect.

Even when you remove a file on POSIX systems, the action itself only eliminates the *name* from the filesystem. That is, there will no longer be an entry where you removed the file. BUT, if any processes still have open handles on the file (as is assuredly the case due to your "in use" comment), the underlying contents are kept. The space occupied by a file is only reclaimed after (1) all references to it on the filesystem are removed, and (2) all open handles are closed by processes owning them.

So it's entirely possible (and sometimes, even desired) to open a file, remove it from the filesystem, but still access it using your handle. This gives you truly private data on a filesystem: nobody can find it, as it has no name, and you are the sole owner of the only handle to access it. As soon as you close your file handle, the contents are eliminated.

Your space will be reclaimed, but not until the process with a handle on that disk image is terminated. (If you force a reboot, this is guaranteed to happen.)

Kraetos
2009-01-31, 21:51
I recently used this command to get rid of an image I started to create as part of my AppleTV HDD upgrade.

You accidentally the whole DMG?

How about a poll?

No /dev/null? Bit bucket? Black hole? Hand over your nerd membership card.