I am unable to get mongod binary path using "db.serverStatus().process" on Ubuntu 20.04. I need to incorporate this command in a script. But "db.serverStatus().process" gives just 'mongod' as output. In Windows it gives exact path. I even included binary path in PATH environment variable and verified the path (echo $PATH).I tried using exact mongo shell path in the mongodb connect string yet same result(not simply mongo --host --port)

  • Why do you need the mongod binary path? According to documentation output mongos or mongod is the desired value, i.e. the value on Windows is actually wrong. Commented Jul 10, 2023 at 11:39
  • Hi @Wernfried Domscheit Thanks for the update. I know <systemctl status mongod> gives exact mongod binary path. But I want similar one using mongodb commands. Is there a way to achieve it.
    – satya
    Commented Jul 11, 2023 at 12:56
  • Try db.serverCmdLineOpts().argv Commented Jul 11, 2023 at 13:09

1 Answer 1


Thank you so much @wernfried-domscheit. It is a good one. Output of "db.serverCmdLineOpts().argv"


[ "/mongo/4.4.22/bin/mongod", "--config", "/etc/mongod.conf" ]

I slightly modified it. Now it is giving what is required. I am just accessing [0] element from the Array which is the exact 'mongod' binary path.

Output of "db.serverCmdLineOpts().argv[0]"



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.