Terminal Help - trash jihad

Discussion in 'Mac Apps and Mac App Store' started by evolu, Dec 4, 2003.

  1. evolu macrumors regular

    Joined:
    Dec 10, 2002
    Location:
    LA la land...
    #1
    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!!!!!
     
  2. yoman macrumors 6502a

    yoman

    Joined:
    Nov 11, 2003
    Location:
    In the Bowels of the Cosmos
    #2
    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.
     
  3. evolu thread starter macrumors regular

    Joined:
    Dec 10, 2002
    Location:
    LA la land...
    #3
    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?
     
  4. yoman macrumors 6502a

    yoman

    Joined:
    Nov 11, 2003
    Location:
    In the Bowels of the Cosmos
    #4
    have you tried....

    just quitting all your open applications except the finder then emptying the trash.

    i'll think up more things later if that doesn't work
     
  5. Gymnut macrumors 68000

    Gymnut

    Joined:
    Apr 18, 2003
    #5
    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.
     
  6. hobbes3113 macrumors regular

    hobbes3113

    Joined:
    Oct 18, 2002
    Location:
    NYC
    #6
    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...
     
  7. stcanard macrumors 65816

    stcanard

    Joined:
    Oct 19, 2003
    Location:
    Vancouver
    #7
    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.
     
  8. kaosfere macrumors member

    Joined:
    Nov 1, 2003
    Location:
    Chicagoland
    #8
    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.
     
  9. stcanard macrumors 65816

    stcanard

    Joined:
    Oct 19, 2003
    Location:
    Vancouver
    #9
    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.
     
  10. kaosfere macrumors member

    Joined:
    Nov 1, 2003
    Location:
    Chicagoland
    #10
    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.
     
  11. evolu thread starter macrumors regular

    Joined:
    Dec 10, 2002
    Location:
    LA la land...
    #11
    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?

     
  12. stcanard macrumors 65816

    stcanard

    Joined:
    Oct 19, 2003
    Location:
    Vancouver
    #12
    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.

    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...
     
  13. evolu thread starter macrumors regular

    Joined:
    Dec 10, 2002
    Location:
    LA la land...
    #13
    thanks stcanard - i will post my results after i get home late tonight.
     
  14. evolu thread starter macrumors regular

    Joined:
    Dec 10, 2002
    Location:
    LA la land...
    #14
    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.
     

    Attached Files:

  15. evolu thread starter macrumors regular

    Joined:
    Dec 10, 2002
    Location:
    LA la land...
    #15
    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!
     
  16. kaosfere macrumors member

    Joined:
    Nov 1, 2003
    Location:
    Chicagoland
    #16
    Re: My Jihad continues!!!

    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.
     
  17. stcanard macrumors 65816

    stcanard

    Joined:
    Oct 19, 2003
    Location:
    Vancouver
    #17
    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!
     
  18. Gymnut macrumors 68000

    Gymnut

    Joined:
    Apr 18, 2003
    #18
    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.
     
  19. evolu thread starter macrumors regular

    Joined:
    Dec 10, 2002
    Location:
    LA la land...
    #19
    will try those sugestions tonight

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

    Gymnut

    Joined:
    Apr 18, 2003
    #20
    Well good luck. Especially good luck whilst you're in the wonderful land of terminal-land.
     
  21. evolu thread starter macrumors regular

    Joined:
    Dec 10, 2002
    Location:
    LA la land...
    #21
    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:

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

    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)
     

    Attached Files:

  22. evolu thread starter macrumors regular

    Joined:
    Dec 10, 2002
    Location:
    LA la land...
    #22
    Thanks Gymnut, but I can't startup in OS 9. Although your solution sounded safest :)

    Any other suggestions are recommended.
     
  23. evolu thread starter macrumors regular

    Joined:
    Dec 10, 2002
    Location:
    LA la land...
    #23
    Re: Re: My Jihad continues!!!

    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...
     
  24. Felix_the_Mac macrumors member

    Joined:
    Aug 18, 2003
    Location:
    UK
    #24
    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.
     
  25. evolu thread starter macrumors regular

    Joined:
    Dec 10, 2002
    Location:
    LA la land...
    #25
    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
     

Share This Page