3

I recently wanted to use the rm command in Terminal on my Mac. To my surprise, it just reponds with:

-bash: rm: command not found

I can use mv, cp, cd, ls etc. However rm somehow doesn't work. I can't use /bin/rm either.

Any ideas what is wrong?

7
  • 2
    Does the file /bin/rm acually exist?
    – Gabe
    Mar 21, 2011 at 7:46
  • 1
    You didn't happen to have run sudo rm rm from the /bin folder by any chance? ;)
    – user24279
    Mar 21, 2011 at 7:48
  • I dont know.. How do i check.. and how do i repair it :S
    – s0mmer
    Mar 21, 2011 at 8:13
  • 1
    your system could be compromised...
    – bubu
    Mar 21, 2011 at 10:14
  • I had a similar problem, trying to delete a "file in use". Initially, it recognised the command, giving a warning and asking for password. However, the file wasn't deleted, but the rm command did not exist anymore. This file has strange behaviour, as it changes name when trying to delete with secure empty trash.
    – user79002
    Apr 29, 2011 at 16:44

2 Answers 2

3

Can you give us the output of the following commands:

stat /bin/rm

and

echo $PATH

Does the problem persists when you open a new terminal?

Did you do anything particular before trying to use the rm command?


Update: The output of your first command confirms that your command rm is missing. Why, I have no idea. Maybe, by error, while being sudo-ed, you did something like /bin/rm /bin/rm.
To fix it, can you try to copy the executable file command from an other mac?

5
  • stat: /bin/rm: stat: No such file or directory and
    – s0mmer
    Mar 21, 2011 at 8:13
  • /opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/texbin:/usr/X11/bin
    – s0mmer
    Mar 21, 2011 at 8:14
  • And no i've tried to restart/ and repair with disc utility and so on.. Just doesnt work.. Maybe my bashcr file is messed up. But i dont know how to fix it :S
    – s0mmer
    Mar 21, 2011 at 8:14
  • @s0mmer: Your "bashcr" is in no way related to missing system commands. Read the output of the 'stat' command again.
    – user1686
    Mar 21, 2011 at 12:44
  • 1
    If you're taking TimeMachine backups of your system, use that to travel back in time on the /bin directory and restore the rm command from the TM backup.
    – Ian C.
    Apr 29, 2011 at 16:47
0

I had a similar occurrence, however, mine was

sudo: rm: command not found

This was caused by incorrectly altering the path in ~/.bash_profile

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy