Installing Mongo and chown /data/db yields "illegal user name" error

phillipmaddox picture phillipmaddox · Oct 23, 2013 · Viewed 13.3k times · Source

I'm installing MongoDB for a Node / Express tutorial and upon creation of the /data/db folder and the following command:

sudo chown 'id -u' /data/db

I received the following error:

chown: id -u: illegal user name

Answer

xoail picture xoail · Feb 25, 2014

You can look for the current username and then try setting the permissions.

$ whoami
username
$ sudo chown username /data/db

Hope that helps.