How to write in the config file

I am completely confused how we create this config file in the first place. I understand what goes in it, but how do we actually open it to write into it or create it in the first place. I am not experienced with command line. The file isnt in my finder because its not actually on my local drive since its virtual. So how do you do this??

Type nano mongo.config, then paste all your config info, when you finish save the file and exit with ctrl + x

you can create config file on your windows machine with notepad and save it as “node1.conf” into C:\Users…\m103\m103-vagrant-env\shared folder… this file will copy config file into ubuntu box… when you do vagrant up --provision and then vagrant ssh and then connect to ubuntu and type after seeing vagrant@m103: create directory by typing sudo mkdir -p /var/mongodb/db/node1 and then type ls -al and then you will see shared folder and type cd /./var/shared and then you will be in that folder, and then type ls -al again and see your copied "node1.conf " is there. and then to move that file into /var/mongodb/db/node1 while you are in /./var/shared directory type sudo mv node1.conf /var/mongodb/db/node1 and then press enter…this will move your config file from shared to /var/mongodb/db/node1 folder… i hope this help.

1 Like

that doesnt work for me. It doesnt recognize nano

Hi Ben,

You can use vi editor. Just copy the content you need to paste to the config file.

To open a file in a current directory:

vagrant@m103:~$ vi mongod_node1.conf

Now, vi editor will open up! To open Insert mode, press i, you will see -- INSERT -- at the bottom.

Paste the content, using [CMD + v] or [Ctrl + v]. You will be able to paste the text.

Now press [Esc] and -- INSERT -- line will disappear.
Type :wq and press [return] or [Enter]

You will be back to the terminal.

I would read this tutorial for vi editor here. :slight_smile:

Thanks, Kanika

2 Likes

when I try to move it from shared directory to var/mongodb/db/node1 it says mv: missing destination file operand after ‘node1.conf.txt/var/mongodb/db/node1/’

There should be space in between the parameters.

mv source_file destination_file

example: If I want to move /shared/node1.txt to /var/mongodb directory, then:

mv /shared/node1.txt /var/mongodb/

Kanika

I’m about to throw in the towel on this one. I’ve spent about two full working days trying ways to access a config file of my making. I can’t find the default config file in the first place. I’ve tried the vi editor from vagrant prompt. CAn’t make head nor tail of what that is bringing up. NOthing I can do anything with. I just have to close the window. I’ve tried running vagrant up after adding a config file to the shared folder as Hakan suggests, but I can’t find any directory or file of that listing with various ls attempts at the vagrant prompt. As to what the home directory for the mongo shell maps to, I have no idea. I’ve searched and searched to find files I’ve created on at the prompt from terminal output. I’ve tried to find directories I’ve created at the terminal prompt. Can’t find anything on my host pc. When I run nano, as Carlos suggest, it brings up an editor, but I can’t paste anything. And as for importing the json lab file at the end of this chapter, I have no chance of locating that file on the shared folder or anywhere else. Was there some ambitious notion professed by course conveners that the virtual box set up was going to make q & a routine and advice compatible to all? The content of this course is quite dense and useful. But these recondite exercises, lacking any detailed advice, such as found by trawling the discussion, even though the discussion solutions didn’t work–they at least provided a chance–has this course stinking to high heaven.