"sudo rm -r ~/.Trash/*" and terminal ?

Discussion in 'Mac Help/Tips' started by BicyclePunk, Feb 11, 2003.

  1. BicyclePunk macrumors regular

    Joined:
    Aug 26, 2002
    Location:
    Somewhere near Philadelphia
    #1
    Ok, this whole thing with the Terminal is new to me. But I am trying to empty my Trash because I have a TOn of locked files (That mysteriously became locked, but that's a different question that can be addressed later). Anyway....I was able to use "sudo rm -r ~/.Trash/*" to clear my Trash once. Now when I try to do it, nothing happens. Here is a sample of what I have done in the Terminal:

    Last login: Tue Feb 11 09:32:59 on ttyp1
    Welcome to Darwin!
    [dsl000-000-000:~] username% login
    login: username
    Password:
    Last login: Tue Feb 11 09:34:56 on ttyp1
    Welcome to Darwin!
    tcsh: Cannot open /etc/termcap.
    tcsh: using dumb terminal settings.
    [dsl000-000-000:~] username% "sudo rm -r ~/.Trash/*"
    sudo rm -r ~/.Trash/*: Command not found.
    [dsl000-000-000:~] username%

    Am I doing something wrong? Is there an easier way to force empty my trash? Thanks in advance.

    ...Jeff
     
  2. FredAkbar macrumors 6502a

    FredAkbar

    Joined:
    Jan 18, 2003
    Location:
    Santa Barbara, CA
    #2
    Re: "sudo rm -r ~/.Trash/*" and terminal ?

    This stuff that I have quoted shouldn't be showing up. This has happened for me occasionally, but to be honest, I don't really know how to fix this. It's pretty simple though, I believe. All I can tell you is that yes you are entering the sudo command correctly--it just isn't working properly. Make sure you are logged in as an administrator...and it won't hurt to repair your disk permissions (using Disk Utility). Sorry I can't help more than that.

    --Fred
     
  3. yzedf macrumors 65816

    yzedf

    Joined:
    Nov 1, 2002
    Location:
    Connecticut
    #3
    try this:

    # sudo rm -fr ~/.Trash/*

    -fr means force and recusrsive (for directories and such)

    ___

    also:

    # cd .Trash
    # ls

    that will move you to the .Trash directory and display what is in directory .Trash

    then try

    # rm -fr *

    ______

    I take it using the GUI is not working? Or are you just wanting to learn the command line interface (CLI)?

    Good luck. :)
     
  4. BicyclePunk thread starter macrumors regular

    Joined:
    Aug 26, 2002
    Location:
    Somewhere near Philadelphia
    #4
    Ok, as far as I know, I am logging in as the administrator since I only have one user, me, on the machine.

    I tried both of yzedf's methods for emptying the trash. The first method didn't work. But when I used the second method and got into the Trash directory, I only saw the new files that I put in the trash. The locked ones, that I can't remove, were not showing. I ran the command and it got rid of the newly trashed files, but the old ones are still stuck in there.

    Basically, I just want to get rid of this stuff in the trash. I was told using the sudo command in the Terminal was the quickest way. I can go into the trash and manually unlock all of the files, but there is a lot of them. And that is really frustrating. Why would these files lock themselves?

    Thanks for any more insight you can provide.
     
  5. peterjhill macrumors 65816

    peterjhill

    Joined:
    Apr 25, 2002
    Location:
    Seattle, WA
    #5
    Just because you are logged into an administrative account, does not mean that you have root priv's. You could set your root password (Applications -> Utilities -> NetInfo Manager ->Security Menu

    You will need to authenticate, enable the root user, set a password. Then you can log out, log in as root, and try to empty the trash.

    You can open your other users trash folder in the gui by using either the Finder -> Go menu, or terminal.

    In go menu, you can select "Open Folder" and type in ~username/.trash

    or in the terminal "open ~username/.trash

    where username is the username of the user with the trash (obviously)

    Those are also handy ways to open your tftpboot directory "/private/tftpboot" and /etc directory. Lots of fun
     
  6. BicyclePunk thread starter macrumors regular

    Joined:
    Aug 26, 2002
    Location:
    Somewhere near Philadelphia
    #6
    The thing is, that when I open ~username/.trash, there is nothing there. But when I peek in the Trash on the GUI, I see all kinds of stuff.
     
  7. yzedf macrumors 65816

    yzedf

    Joined:
    Nov 1, 2002
    Location:
    Connecticut
    #7
    What are the names of the locked files? Are they files you have created? System files?

    As for "administrator" this is not Windows 2000. By default, you are NOT the administrator. When you boot into OS X you have 2 accounts on the machine. Yours (mine would be called "yzedf") and the "root" account. Your account does not have permission to do certain things. This is for your safety. Newbies have a tendency of deleting things that they don't think they need. Most often, these turn out to be files that are necessary for the system to run.

    Another thing, if you are doing the same task over and over again, as "root" user (sudo gives you root access for 1 command only), you want to do the following:

    # su
    # enteryourpasswordhere

    then you will be logged in as root (administrator).

    do what you need. then:

    # Ctrl-d

    (hold down Ctrl key, and type the letter d)

    or you can use:

    # logout (maybe exit, can't remember...)

    Please be careful. If you don't recognize the file, and it is locked, there may be good reason. Go to Google and do a search for the exact name of the file, including extension. Most likely, you will find out what it is for, and if it should be there or not.
     
  8. peterjhill macrumors 65816

    peterjhill

    Joined:
    Apr 25, 2002
    Location:
    Seattle, WA
    #8
    ah, try this:
    [TITAN:~] phill% cd /
    [TITAN:/] phill% su
    Password:
    [TITAN:/] phill# cd .Trashes/
    [TITAN:/.Trashes] phill# ls -a

    See what that says. From here try your:

    rm -ri /.Trashes/*
     
  9. daytona63 macrumors member

    Joined:
    Feb 11, 2002
    Location:
    San Diego, CA
    #10
    This could work too

    you could also create a new folder on your desktop, then move all the files in the Trash to that folder, then remove that folder from the command line using

    sudo rm -r nameofyourfolder
     
  10. BicyclePunk thread starter macrumors regular

    Joined:
    Aug 26, 2002
    Location:
    Somewhere near Philadelphia
    #11
    yzedf: the stuff in the trash I need to get rid of is stuff I made myself or cached web stuff or documentation. Nothing important, I can see. And the:
    # su
    # enteryourpasswordhere

    didn't work for me. That's as far as I got.

    peterjhill: First off, I could really go for a Primanti's and an IC Light right about now. Secondly, I couldn't get the phill% cd / command to work. I assume I leave off the [TITAN:/~] part, right? Thanks.
     
  11. yzedf macrumors 65816

    yzedf

    Joined:
    Nov 1, 2002
    Location:
    Connecticut
    #12
    looks to me like you need to chmod all the files in your trash.

    # chmod 777 * (when you are in the trash directory logged in as root)

    # rm -f *

    or

    # sudo chmod 777 *

    # rm -f * (while in trash directory)
     
  12. BicyclePunk thread starter macrumors regular

    Joined:
    Aug 26, 2002
    Location:
    Somewhere near Philadelphia
    #13
    I'm going to try that chmod thing next time this happens. Thanks. I did what daytona63 suggested and all that stuff is gone now. Thanks for all your help!
     
  13. yzedf macrumors 65816

    yzedf

    Joined:
    Nov 1, 2002
    Location:
    Connecticut
    #14
    cool

    hopefully won't happen again ;)
     

Share This Page