The sudo and chown create lot of problem

Hi

I am badly stuck in in this sudo & chmod command i tried lot but could not able to run

validate_lab_change_dbpath lab homework

Please be more clarify and step to step proper execution step should describe by university .

:rage:

Hi Nagesh_46115,

Sorry for your experience. We will take your note and will do the needful.

For your query, we mentioned use sudo because it is managed by root, so it will require root access. In simple words, if I want to create directory /var/kanika, I will run:

vagrant@m103:~$ sudo mkdir /var/kanika

To make sure I will list the directory to see the permissions set for this directory:

vagrant@m103:~$ ls -l /var/
total 56
drwxr-xr-x  2 root root   4096 Sep 27 06:25 backups
drwxr-xr-x 11 root root   4096 Jul 16 21:40 cache
drwxr-xr-x  3 root root   4096 Jul 17 09:43 chef
drwxrwxrwt  2 root root   4096 Sep 27 06:25 crash
drwxr-xr-x  2 root root   4096 Oct 23 14:34 kanika

You can see its user is set as “root root”. To change the ownership to vagrant, I will do something like this:

vagrant@m103:~$ sudo chown vagrant:vagrant /var/kanika

I hope it clears now! Let me know if you need more help!

Kanika

vagrant@m103:~ ls -l /var/ total 52 drwxr-xr-x 2 root root 4096 Oct 23 06:45 backups drwxr-xr-x 12 root root 4096 Oct 23 06:44 cache drwxr-xr-x 3 root root 4096 Oct 22 13:13 chef drwxrwxrwt 2 root root 4096 Oct 15 20:45 crash drwxr-xr-x 50 root root 4096 Oct 23 06:44 lib drwxrwsr-x 2 root staff 4096 Apr 10 2014 local lrwxrwxrwx 1 root root 9 Oct 15 20:41 lock -> /run/lock drwxrwxr-x 11 root syslog 4096 Oct 23 05:17 log drwxr-xr-x 3 root root 4096 Oct 22 13:15 m103 drwxrwsr-x 2 root mail 4096 Oct 15 20:41 mail drwxr-xr-x 2 vagrant vagrant 4096 Oct 23 14:46 mongodb drwxr-xr-x 2 root root 4096 Oct 15 20:41 opt lrwxrwxrwx 1 root root 4 Oct 15 20:41 run -> /run drwxr-xr-x 5 root root 4096 Oct 15 20:42 spool drwxrwxrwt 2 root root 4096 Oct 23 09:00 tmp vagrant@m103:~ cd mongodb/
vagrant@m103:~/mongodb$ mkdir db

vagrant@m103:~/mongodb$ ls -l
total 4
drwxrwxr-x 2 vagrant vagrant 4096 Oct 23 14:48 db

Ok till this,

this is .cfg

storage:
dbPath: “/var/mongodb/db”

net:
bindIp: “127.0.0.1,192.168.103.100”
port: 27000

still error:

2018-10-23T14:50:45.601+0000 I CONTROL [initandlisten] options: { config: “/home/vagrant/mongo_lab.cfg”, net: { bindIp: “127.0.0.1,192.168.103.100”, port: 27000 }, storage: { dbPath: “/var/mongodb/db” } }
2018-10-23T14:50:45.601+0000 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /var/mongodb/db not found., terminating

Now,tell me solution.

Thank you.

Well… did you actually create the data directory?? Because in your example it looks like you did not. You created /tmp/mongodb/db, not /var/mongodb/db. So either change your config, or create the right location.