Unable to save the configuration file by :wq

I follow the lecture and trying to finish Chapter 2: Replication ### Lab: Deploy a Replica Set

Here are the command that i typed in the terminal
mkdir -p /var/mongodb/pki/
openssl rand -base64 741 > /var/mongodb/pki/m103-keyfile
chmod 400 /var/mongodb/pki/m103-keyfile
mkdir -p /var/mongodb/db/1
mongod -f mongod_1.conf
cp mongod_1.conf mongod_2.conf
cp mongod_1.conf mongod_1.conf
vi mongod_2.conf
and i tried to edit the configuration file as the image above,
even i type :wq and hit enter, it still stay in the configuration file and i could not save and exit…

Any steps did i do wrong?

Thank you!

You have to hit the “escape” key [ESC] before doing :wq
[ESC] exits from visual mode to command mode.
In command mode you can do :wq

You are not supposed to use vi in the IDE. The only files your are supposed to edit are in the top right pane labelled with Code Editor. Changes are written automatically when the mouse cursor leave the given file.


The lab instructions indicate:

There are three configuration files in your IDE workspace, but they are incomplete.

Update these configuration files

By doing the cp you have overwritten which was good but incomplete

Starting mongod with mongod_1.conf without completing it like indicated.

The lab indicates to use that file but it did not mentioned that you needed to create it. A simple ls would have reveal that it is there.

Like all other labs from the same course you should edit the file in the provided code editor.

But what is really really funny is that you know about vi but not about


Hi Steeve and Jack

Thank your for your explanations.

I have finished the lab.

Really thank you!!!