I have 2 questions.
i) I have installed MongoDB on Ubuntu 20.04 using apt MongoDB install
I see the below permissions . Are they correct?
id mongodb
uid=116(mongodb) gid=65534(nogroup) groups=65534(nogroup),122(mongodb)
ii) I installed another MongoDB manually on Ubuntu 20.04 and created MongoDB data folder as /mongodb/replsetname/data
What should be the permissions on the above directory structure for MongoDB user
chown -R mongodb:mongodb /mongodb -------> is this correct
chmod -R 755 /mongodb -------> is this correct
What are the permissions on the data directory on the system where you installed automatically?
ls -lrt /var/lib/mongodb
total 340
-rw------- 1 mongodb mongodb 21 Jun 9 06:48 WiredTiger.lock
-rw------- 1 mongodb mongodb 50 Jun 9 06:48 WiredTiger
-rw------- 1 mongodb mongodb 114 Jun 9 06:48 storage.bson
drwx------ 2 mongodb mongodb 4096 Jun 9 06:52 testdb
drwx------ 2 mongodb mongodb 4096 Jun 9 06:55 local
drwx------ 2 mongodb mongodb 4096 Jun 9 06:55 config
drwx------ 2 mongodb mongodb 4096 Jun 9 06:55 admin
drwx------ 2 mongodb mongodb 4096 Oct 16 01:23 journal
drwx------ 2 mongodb mongodb 4096 Oct 16 03:43 diagnostic.data
-rw------- 1 mongodb mongodb 1796 Oct 16 03:43 WiredTiger.turtle
-rw------- 1 mongodb mongodb 32768 Oct 16 03:43 WiredTigerHS.wt
-rw------- 1 mongodb mongodb 36864 Oct 16 03:43 sizeStorer.wt
-rw------- 1 mongodb mongodb 36864 Oct 16 03:43 _mdb_catalog.wt
-rw------- 1 mongodb mongodb 192512 Oct 16 03:43 WiredTiger.wt
-rw------- 1 mongodb mongodb 0 Oct 16 03:43 mongod.lock
ls -lrt /var/log/mongodb
total 97948
-rw------- 1 mongodb mongodb 100292917 Oct 16 03:43 mongod.log
It is clear from the above output that just the last directory named “mongodb” in side /var/lib/mongodb and /var/log/mongodb are owned by the OS user “mongodb”
My query is incase I create a /mongodb/replsetname/data
What should be the permissions for MongoDB user
chown -R mongodb:mongodb /mongodb -------> is this correct
chmod -R 755 /mongodb -------> is this correct
What I mean
can mongodb user own whole /mongodb, instead of having permissions on the last sub directory as seen in default installation
Is there any harm, if mongodb OS user owns whole /mongodb