Unable to create DBpath at /Var using Virtual box

I am working on to complete the “LAB: Change the default DB path”.

Lab instructions asking to create DB path at “/var/mongodb/db”. In virtual box I login as vagrant and I think there is no root or sudo to root for vagrant. How to over come this and make vagrant write in /var dir to be used for db path change to start mongod process.

since vagrant doesn’t have write permission on /var directory its failing with the below error:

If anyone faced this error how to over come this and do start mongod for validation?

sudo is available for vagrant
It must have been mentioned in your lectures.Please check

sudo mkdir -p /var/mongodb/db
After creating dir need to change permissions
sudo chown vagrant:vagrant /var/mongodb/db

1 Like

You are correct, I over looked/forget the fine prints. Thanks for your steps as this helps all.