Reputation: 73
I'm using Ubuntu 16.04, and I can't understand what's difference between using
sudo service mongod start
and
mongod
In mongodb official documentation here
said that to start mongodb just use sudo service mongod start
, and its log stores in /var/log/mongodb. However, I try to run mongodb using mongod
this way, log shows on terminal, and after I turn off the terminal, I can not find the log file.
It is confused.
Upvotes: 3
Views: 986
Reputation: 7230
sudo
- Runs the command as root
.
service
- Manages the following program as a daemon
(background process).
mongod
- Obviously the MongoDB program in question.
start
- A command that tells service
what to do with the program in question.
Together, we get "I want to start mongod
as a background process, and I want to run it as root
so it has permission to do the things it needs to do". Running mongod
by itself, however, runs the program in an ordinary fashion, i.e. as a foreground process. Typically you want to run it as a background process so that you're free to do other things, e.g. connecting to the database via shell access.
This is pretty simplified, but it should explain what you actually need to know at this point in time.
Upvotes: 5