Change dbPath on Ubuntu

Thanks. Here’s the result when I tried that:

user@machine:~$ sudo systemctl status mongod
[sudo] password for user: 
● mongod.service - MongoDB Database Server
     Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset>
     Active: active (running) since Wed 2020-06-03 18:28:28 NZST; 5h 5min ago
       Docs: https://docs.mongodb.org/manual
   Main PID: 902 (mongod)
     Memory: 209.8M
     CGroup: /system.slice/mongod.service
             └─902 /usr/bin/mongod --config /etc/mongod.conf

Jun 03 18:28:28 machine systemd[1]: Started MongoDB Database Server.

When I look inside the /lib/systemd/system/mongod.service file I see:

[Unit]
Description=MongoDB Database Server
Documentation=https://docs.mongodb.org/manual
After=network.target

[Service]
User=mongodb
Group=mongodb
EnvironmentFile=-/etc/default/mongod
ExecStart=/usr/bin/mongod --config /etc/mongod.conf
PIDFile=/var/run/mongodb/mongod.pid
# file size
LimitFSIZE=infinity
# cpu time
LimitCPU=infinity
# virtual memory size
LimitAS=infinity
# open files
LimitNOFILE=64000
# processes/threads
LimitNPROC=64000
# locked memory
LimitMEMLOCK=infinity
# total threads (user+kernel)
TasksMax=infinity
TasksAccounting=false

# Recommended limits for for mongod as specified in
# http://docs.mongodb.org/manual/reference/ulimit/#recommended-settings

[Install]
WantedBy=multi-user.target

It may just be my lack of knowledge about linux but I don’t see the sort of statement your describe. There is the line:

ExecStart=/usr/bin/mongod --config /etc/mongod.conf

but that’s the same config file I earlier wrote of wanting to be able to change–but when I do so, mongod will not start.

Is this line important?:

EnvironmentFile=-/etc/default/mongod

The thing is, I don’t know what the leading - is doing there. There’s no file at:

/etc/default/mongod