3 Replies Latest reply: Feb 5, 2012 10:34 AM by BobHarris
afzalur-rahman Level 1 Level 1

Hello, when i type sudo it show bellow message


Arifur-Rahmans-MacBook-Pro:~ arif$ sudo

-bash: sudo: command not found


when i type ls


Arifur-Rahmans-MacBook-Pro:~ arif$ ls

-bash: ls: command not found


Please help me i am not able to work anythings.

MacBook Pro, Mac OS X (10.6.8)
  • BobHarris Level 6 Level 6

    Chances are your PATH environment variable has been messed up.

    Did you follow some instructions to modify your PATH and store it in .profile (or .bash_profile, or .bash_login, or .bashrc)?  This is typically how PATH gets messed up.


    If you have created one of the above mentioned files, you can most likely either delete it or rename it using


    /bin/mv .profile profile.save # rename it


    /bin/rm .profile  # delete it


    Substitute the name of the shell initialization file you created for .profile


    Then quit Terminal and start a new session.


    If this is not what happened, then please provide the output from the following command:


    echo $PATH

  • afzalur-rahman Level 1 Level 1

    I am new user on mac.  So please told me how i can change this.


    When i type $path it show


    Arifur-Rahmans-MacBook-Pro:~ arif$ $PATH

    -bash: /usr/local/mongodb-osx-x86_64-1.8.2/bin:$: No such file or directory




    Please note that py private folder is not showing . It is some how hidden.


    So what can i do now.

  • BobHarris Level 6 Level 6

    When I said type


    echo $PATH


    I did mean PATH in ALL CAPITALS.  When working on the Unix side of Mac OS X, as weill all Unix systems upper and lower case do matter.


    But from the error message, I can see that somewhere along the way, mongodb (a database package), and the modification of PATH was done incorrectly.

    If you installed MongoDB, AND if the instructions had to modify your .profile (or perhaps .bash_profile), then either their instructions were wrong, or you missed a step, which explains why you can not enter commands are not found


    PATH is a Unix environment variable that contains a colon separate list of directories where the shell will look for commands when you enter them at the command prompt.


    So your choices are delete the offending .profile (or perhaps .bash_profile) and forget about MongoDB, or if you do need MongoDB, then fix your .profile (or .bash_profile) so it has a properly formed PATH environment variable.


    Fixing this would look like


    /bin/ls -a         # this will show you all the files starting with a period (dot) as in .profile or .bash_profile
    /usr/bin/nano .profile


    now in this text editor use the arrow keys, and the delete key to find and delete offending text, then type in the corrected text.  Nano gives you a menu at the botton of the editor with additional commands.  ^O (Control-O) writes out any changes you made.  ^X (Control-X) exits from Nano.


    You want your PATH variable to look like (REMEMBER UPPER/lowercase is IMPORTANT)  ALSO spaces or nospaces are important.


    export PATH="/usr/local/mongodb-osx-x86_64-1.8.2:$PATH"


    NOTICE there is a colon between the MongoDB directory path, and the $PATH.  The $PATH will append your existing PATH to the end of the new PATH environment variable you are setting up.  The entire PATH string is enclosed in double quotes.  ALSO NOTICE, there is only 1 space between export and PATH.  No spaces anywhere else in the line.


    Again, I used .profile as the most likely file name, HOWEVER, your shell will look for 1 of 3 different initialization files starting with






    If will use the first file it finds in the above order and stop looking as soon as it finds a match.  So it is important that you edit the correct file.  The


    /bin/ls -a


    command will tell you want leading period filenames exist in your home directory


    I'll also give you one word of caution.  When playing on the Unix side of Mac OS X, and following instructions you do not understand, it is generally wise to have a very recent full backup of your system.  There are some commands that can make your system unusable should you enter them blindly.


    Message was edited by: BobHarris