Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

evolu

macrumors regular
Original poster
Dec 10, 2002
232
0
LA la land...
I'm a terminal n00b

I have a stubborn trash file that no app on versiontracker will delete...

The file is apparently always in use by another application.

Is there a way to stop the usage of this file so i can delete it finally?

Thanks for any help friends!!!!!
 

yoman

macrumors 6502a
Nov 11, 2003
635
0
In the Bowels of the Cosmos
do you know the name of the file?

Maybe you could use the Activity Monitor in Applications/Utililities
.
then Find the process and kill it.

I'm not sure if this will work b/c I don;t fully understand your problem.
 

evolu

macrumors regular
Original poster
Dec 10, 2002
232
0
LA la land...
i may not know all the ins and outs of activity monitor, but I only see apps there. Unfortunately I don't know what app is currently using the file... Is there a way to see what files are being used?

I should try and explain more clearly:

there is an incomplete .dmg file i downloaded from poisoned that is now in my trash. When I empty trash, everything empties but that file. When I secure empty the trash, a box pops up saying the file can't be deleted because it is in use.

I can't change the name of the file.

if i select the file while in column view the finder restarts!

I've downloaded every trash script/program on versiontracker and none of them work.

I look in activity monitor and to my sophmore eye there's the usual apps running.

Hope that clarifies a bit - any other suggestions?
 

Gymnut

macrumors 68000
Apr 18, 2003
1,887
28
I've had this same problem when I installed Windows Media Player 9. I'm not sure what happened but the application icon itself for WMP9 turned into a document looking icon indicating something had gone wrong. I tried trashing the application itself but got a message saying that some things were still in use. Tried some people's suggestions to going into the terminal to no avail. Simply I left the annoying app on my desktop, restarted in OS 9 from the startup disk and trashed it in OS 9. Hope that helps.
 

hobbes3113

macrumors regular
Oct 18, 2002
133
0
NYC
You can also try to log out/in and delete the file. I have found that this works most of the time. If not, just reboot, that will definately kill all processes, and if the file is in the trash, it cannot load...
 

stcanard

macrumors 65816
Oct 19, 2003
1,485
0
Vancouver
Here's how you can find out what is using the file:

lets say you have a file "mydata.txt". From the terminal type:

lsof | grep mydata.txt

You should get one line back (maybe more). If there is nothing returned, nothing has it open.

Otherwise you will see a line that starts like this:

more 27626 username ....

That means:
The program 'more' has the file open
The process id of the program is 27626
The user 'username' is running the program.

Now if you want you can go to activity monitor and kill the program.

To delete it no questions asked, (in order of increasing danger):

rm file
rm -f file

If you're desperate, and know the file will not cause problems (only if you're certain!):

sudo rm -f file

If killing the program plus a 'sudo rm -f' doesn't get rid of the file it is not meant to be deleted.

P.S. Just to get into the trash from the command line, type;

cd ~/.Trash

Don't miss the "." in that command.
 

kaosfere

macrumors member
Nov 1, 2003
69
0
Chicagoland
Originally posted by stcanard

Now if you want you can go to activity monitor and kill the program.

You don't need to go to the activity monitor. As long as you're in the terminal, you can kill it with just kill 27626. If that doesn't take it down, try kill -9 27626.
 

stcanard

macrumors 65816
Oct 19, 2003
1,485
0
Vancouver
Originally posted by kaosfere
You don't need to go to the activity monitor. As long as you're in the terminal, you can kill it with just kill 27626. If that doesn't take it down, try kill -9 27626.

Well, yeah, but if he's new to terminal but is familiar with Activity Monitor (as suggested in the comments), it's a lot easier and a less dangerous.

Plus I believe activity monitor will automatically prompt for a password for root owned processes? That's a nice feature.

Last thing I want to do is tell somebody unfamiliar with a command line to try something like 'sudo kill -KILL $pid' Typos on that command will do nasty things.
 

kaosfere

macrumors member
Nov 1, 2003
69
0
Chicagoland
Originally posted by stcanard
Last thing I want to do is tell somebody unfamiliar with a command line to try something like 'sudo kill -KILL $pid' Typos on that command will do nasty things.

Eh, I always figured you might as well teach 'em, but teach 'em to be careful at the same time. Either way will get the job done, though, true.
 

evolu

macrumors regular
Original poster
Dec 10, 2002
232
0
LA la land...
you are so rad! I have to wait till I get home to try this - but this was EXACTLY the type of post I was looking for.

How does one learn more about using the terminal anyway?

Originally posted by stcanard
Here's how you can find out what is using the file:

lets say you have a file "mydata.txt". From the terminal type:

lsof | grep mydata.txt

You should get one line back (maybe more). If there is nothing returned, nothing has it open.

Otherwise you will see a line that starts like this:

more 27626 username ....

That means:
The program 'more' has the file open
The process id of the program is 27626
The user 'username' is running the program.

Now if you want you can go to activity monitor and kill the program.

To delete it no questions asked, (in order of increasing danger):

rm file
rm -f file

If you're desperate, and know the file will not cause problems (only if you're certain!):

sudo rm -f file

If killing the program plus a 'sudo rm -f' doesn't get rid of the file it is not meant to be deleted.

P.S. Just to get into the trash from the command line, type;

cd ~/.Trash

Don't miss the "." in that command.
 

stcanard

macrumors 65816
Oct 19, 2003
1,485
0
Vancouver
Originally posted by evolu
you are so rad! I have to wait till I get home to try this - but this was EXACTLY the type of post I was looking for.

Thanks, glad to be of service :) lsof is one of those incredibly useful programs that for some odd reason doesn't seem to be a default install on too many systems.

How does one learn more about using the terminal anyway?

Years of practice

Seriously, there are some good threads with suggestions on this site.

It's a unix structure, so any of the introduction to unix / linux books or websites are a good start. Try googling something like 'unix command basics'

In the terminal the command 'man' is like help. if you type 'man lsof' you'll get the help page for it (well within unix definitions of help anyway).

man -k will do a keyword search. So if you say "man -k 'open file'" you will see al list of commands that may relate to open files.

The unix system is incredibly complex. I've been using it for over a decade and I'm only just scratching the surface.

Whenever I have something I want to do and don't know how google is my friend...
 

evolu

macrumors regular
Original poster
Dec 10, 2002
232
0
LA la land...
My Jihad continues!!!

ok - so the new drama with this file:

I contains some unusual characters in it that I can't quite recreate in the Terminal...

There's a chinese character for whatever reason...

These characters are not cutting and pasting well so I'll attach an image:

When I try and rename the file the finder crashes. How do I rename from the terminal? Also, the terminal doesn't seem to like parentheticals in the filename.

Thanks again.
 

Attachments

  • trash window.jpg
    trash window.jpg
    40.9 KB · Views: 141

evolu

macrumors regular
Original poster
Dec 10, 2002
232
0
LA la land...
by the way - i put it in those other folders as a way to try and change the ownership of the uppermost folder, then applying the changes to the file inside. Now they are all kind of stuck there.

Nothing like showcasing your retarded moves on the net!
 

kaosfere

macrumors member
Nov 1, 2003
69
0
Chicagoland
Re: My Jihad continues!!!

Originally posted by evolu
When I try and rename the file the finder crashes. How do I rename from the terminal? Also, the terminal doesn't seem to like parentheticals in the filename.

Try using tab completion, and see what that does -- enter as much of the name as you can, then hit tab and it should find the file and fill out the rest of the name the way it wants it to look.

In a directory with just one file in it, you can just hit tab, and it will autofill it. Generally speaking, you need only specify enough of the name to uniquely identify the file.

As for the parens, you can get around problems there by either backslash-escaping them (e.g, do '\(' rather than '(' and '\)' rather than ')'), or by enclosing the entire file name in single-quotes.
 

stcanard

macrumors 65816
Oct 19, 2003
1,485
0
Vancouver
Okay give this a try:

cd ~/.Trash/tra****/PoisonedDownloads

rm -fi *

Don't miss the 'i". It tells rm to prompt before deleting a file so you don't accidentally delete something good.

in the terminal use a backslash to specify special characters. So if you have something like:

(Really *ed up) file name.doc

You can specify:

rm \(Really\ \*ed\ up\)\ file\ name.doc

If you have a directory you can't cd into, wildcards work wonders. The first command can also be written like this:

cd ~/.Trash/tra****/P*

If you're confident you can do this to get rid of everything in the trash:

cd ~/.Trash
sudo rm -rfi *

Should delete everything in your trash.

It it seems to be asking to delete things you don't want deleted hit ctrl-c to stop the process!

[Edit]
P.S. Those stars appear to be automatically masking a naughty word that is in your filename. Use the real filename and not 4 *'s. I am a bit surprised that the forum won't let me use words that contain other strings!
 

Gymnut

macrumors 68000
Apr 18, 2003
1,887
28
Just trash it in 9 if your computer is able to startup in OS9. I've tried removing items from the terminal and the best advice is if you don't know what you're doing in there, it's best left alone.
 

evolu

macrumors regular
Original poster
Dec 10, 2002
232
0
LA la land...
will try those sugestions tonight

Gymnut, stcanard and kaosfere - I will try your suggestions tonight... Thanks for the multiple paths of attack!
 

Gymnut

macrumors 68000
Apr 18, 2003
1,887
28
Well good luck. Especially good luck whilst you're in the wonderful land of terminal-land.
 

evolu

macrumors regular
Original poster
Dec 10, 2002
232
0
LA la land...
OK - first thing I did is log in as root just to see if I could delete this file as a root user.

I did a search in the finder and found the Tra**** folder - selected it and hit delete which brought it into the root user's trash.

Then I tried stcanard's suggestion:

Originally posted by stcanard
Okay give this a try:

cd ~/.Trash/tra****/PoisonedDownloads

rm -fi *

Don't miss the 'i". It tells rm to prompt before deleting a file so you don't accidentally delete something good.

Ok - Terminal comes back saying "tcsh: rm: No match.

If you're confident you can do this to get rid of everything in the trash:

cd ~/.Trash
sudo rm -rfi *

Should delete everything in your trash.

it says "remove tra****?" i type y (hit return)

it says "remove tra****/PoisonedDownloads?" i type y (hit return)

it says "rm: rm: tra****/PoisonedDownloads: Directory not empty
rm: tra****: Directory not empty"

and my Jihad continues.

Here's a screenshot: (Notice I am logged in as root)
 

Attachments

  • term window.jpg
    term window.jpg
    74 KB · Views: 104

evolu

macrumors regular
Original poster
Dec 10, 2002
232
0
LA la land...
Originally posted by Gymnut
Just trash it in 9 if your computer is able to startup in OS9. I've tried removing items from the terminal and the best advice is if you don't know what you're doing in there, it's best left alone.

Thanks Gymnut, but I can't startup in OS 9. Although your solution sounded safest :)

Any other suggestions are recommended.
 

evolu

macrumors regular
Original poster
Dec 10, 2002
232
0
LA la land...
Re: Re: My Jihad continues!!!

Originally posted by kaosfere
Try using tab completion, and see what that does -- enter as much of the name as you can, then hit tab and it should find the file and fill out the rest of the name the way it wants it to look.

In a directory with just one file in it, you can just hit tab, and it will autofill it. Generally speaking, you need only specify enough of the name to uniquely identify the file.

As for the parens, you can get around problems there by either backslash-escaping them (e.g, do '\(' rather than '(' and '\)' rather than ')'), or by enclosing the entire file name in single-quotes.

Tab completion is works well until it gets to the actual file I want to delete.

What I did was type ".Trash" and hit TAB which extended the name out to:

"/.Trash/Tra****/"

I hit tab again and it extended to

"/.Trash/Tra****/PoisonedDownloads"

Hit tab again and I get an error beep. It won't go further.

I was logged in as root when I did this BTW...
 

Felix_the_Mac

macrumors member
Aug 18, 2003
92
0
UK
I assume by now the file is no longer in use, otherwise you won't be able to do anything with it.

If that is the case try renaming it:

mv f*.dmg 123

then you will no longer have any problems with the special characters.
 

evolu

macrumors regular
Original poster
Dec 10, 2002
232
0
LA la land...
Thanks for the help guys - I'm leaving it in the root's trash for now and will win my jihad with a "clean install" once I'm finished with a project I'm working on.

Thanks for all your help - I learned a lot.

Macrumors is the best!!

evolu
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.