Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to install MongoDB in ubantu 12.04, but I don't have any idea to add
deb dist 10gen
code in
file. I used
sudo vim /etc/apt/sources.list
for this propose. But I am unable to edit the file. Does anybody know how I can resolve this issue?

share|improve this question

migrated from Jul 17 '12 at 1:43

This question came from our site for professional and enthusiast programmers.

What error are you getting? What "is not a success"? As indicated by parvin, the tutorial page contains everything that you need on a step-by-step basis. Apend the line "deb dist 10gen" to the end of the /etc/apt/sources.list file. – Mark Hillick Jul 16 '12 at 8:37
@MarkHillick, I can't add the deb dist 10gen line of code in /etc/apt/sources.list file – Ganesh kunwar Jul 16 '12 at 8:40
What error do you receive? Are you not in the sudoers group? – Mark Hillick Jul 16 '12 at 8:49
Can you post a screenshot of your error? Or the text? It's too vague so far? What's the output of "ls -la /etc/apt/sources.list"? – Mark Hillick Jul 16 '12 at 9:02
Please do what people ask you instead of repeating yourself. – Lucas Kauffman Jul 20 '12 at 18:36

You can follow the instructions in the MongoDB tutorial page.

share|improve this answer
Those are the instructions he followed. That's where the addition of 10gen repo comes from. – Mark Hillick Jul 16 '12 at 10:39
Since I don't know which instructions he followed, i suggest him to use the step by step instructions on the MongoDB page. – parvin Jul 16 '12 at 10:44
He said what instructions he followed. Your answer is essentially a copy of what he did. – Mark Hillick Jul 18 '12 at 13:40

here is my solution, copy following in your install_mongo.bash file

    sudo apt-key adv --keyserver --recv 7F0CEB10
    echo "deb dist 10gen" | sudo tee -a /etc/apt/sources.list.d/10gen.list
    sudo apt-get update
    sudo apt-get install mongodb-10gen

and then execute bash install_mongo.bash

share|improve this answer

I believe it's a file permission issue. Execute the following commands:

sudo su - 
echo "deb dist 10gen" >> /etc/apt/sources.list 

That will make sure that you really executed the commands as root.

This should work, but a more clean way how to do it in Ubuntu 12.04 is to add the new repository in /etc/apt/sources.list.d/10gen.list.

Now the only think left is to install it.

apt-get update
apt-get install mongodb-10gen
share|improve this answer
Ganesh used sudo, how is this solution different? – Mark Hillick Jul 18 '12 at 13:54
Double checking if he used all the commands right. I guess because he is a novice there is a chance that he missed some steps. So with my approach he will make sure that he is logged as root. If even after that he is not able to write the file we can exclude user permission problem and look for other causes. Also I added the ending step how to actually install the program and changed the location of the repo file, which is a much more widely used approach. – golja Jul 18 '12 at 23:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.