Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Databases

Installing mongodb on Mac (Yosemite)

Using the terminal I've successfully installed mongodb via Homebrew.

Following the video, I typed the following in the terminal, and as in the example provided in the video got a "permission denied" message. mkdir -p /data/db

The video's instructions are to then try typing "sudo" in front of the above command. I didn't have sudo on my machine so I downloaded it. But how do I get a password for sudo (that's what the terminal is now asking me for)?

3 Answers

Nathan Tallack
Nathan Tallack
22,160 Points

Sudo is an internal command for your shell. You should not have had to download it. Before you use it please verify you are using the one that comes with the platform not some third party one that could be a trojan. Use the following commands.

$ which sudo
/usr/bin/sudo
$ ls -al /usr/bin/sudo
-r-s--x--x  1 root  wheel  168448 Dec  3 19:35 /usr/bin/sudo

Once you have verified you are using the sudo that is in your /usr/bin (with the which command) and that it looks the same as mine (with the ls command) you can use sudo by using the same password you log into your workstation with when it boots. If you have forgotten this password go to your "System Preferences" (Apple icon in top left of your screen) and "User Preferences" and click "Change Password" on your user account and follow the prompts.

Let me know if you have any problems. :)

Thanks Nathan. I followed your suggestion This is what I have. It looks fine until I try to run the course command again.

Snowcats-MacBook-Pro:~ snowcat$ which sudo
/usr/bin/sudo
Snowcats-MacBook-Pro:~ snowcat$ ls -al /usr/bin/sudo
-r-s--x--x  1 root  wheel  164560 Sep  9  2014 /usr/bin/sudo
Snowcats-MacBook-Pro:~ snowcat$ mkdir -p /data/db
mkdir: /data/db: Permission denied
Snowcats-MacBook-Pro:~ snowcat$ sudo mkdir -p /data/db
Password: 

At "password" there is one dot highlighted. When I attempt to type the password nothing happens (my cursor stays stuck and nothing types out). I hit enter, and I get the same experience. The only way to exit is to hit enter 3 times. Then I'm able to type "clear".

Password:
Sorry, try again.
Password:
Sorry, try again.
Password:
Sorry, try again.
sudo: 3 incorrect password attempts   [at this point I'm able to type 'clear']
Snowcats-MacBook-Pro:~ snowcat$ 
Nathan Tallack
Nathan Tallack
22,160 Points

You won't see the password as you are typing it. So the behaviour you are experiencing is correct.

That password needs to be correct. It is the one that matches your user account. Go into the system preferences and choose change password in the user preferences like I said. Once you have set the password correctly then you can use that password with your sudo command. :)

Your answer was very helpful Nathan. Thanks again.

I found the other missing element here; http://osxdaily.com/2015/02/04/terminal-wont-show-password-when-typed/

Terminal does let you type your password, it just doesn’t look like it. The cursor on screen will not move, and there is no indicator the password is being entered at all. This is intentional and serves as a security mechanism, unlike entering a password into a web form or a standard GUI login screen, which is typically masked as asterisks like ******** or bullets like •••••••••••••, the lack of anything showing is entirely intentional and there is no such indication of entering passwords at the command line. The reason is rather simple, it provides no indication for how long a password is, offering some further obfuscation to password entry.

Thanks again Nathan. Looks like we posted at the same time!