What is the meaning of -d flag on command line


Sorry for the beginner question. Unfortunately, I was not able to find an answer online…

I spent some time installing an MQTT broker on my Pi3 OSMC box. I then wanted to configure it to autorun using systemd. I setup a .service file, and struggled to get it running.

One of the problems I had was with the ExecStart command. Example .service files I saw used ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf -d. But I found the service would not run while the -d flag was included (and ran fine as soon as I removed it).

Is someone please able to explain what the -d flag means? I’d especially appreciate a link to documentation (so I can figure out why I was not able to find this on my own).

Thanks!! :slight_smile:


Try setting type=forking and have a pid file
Here is an example from elsewhere (I don’t know if it is right).

This tells the startup process that the invoked application will “fork” … meaning it will start a child process and the invoked process will exit. This is what the -d (daemon) switch asks it to do.


Thanks, I’ll give that a try.

Mind you, it’s working now (with the -d removed), so mostly I am just curious to learn.

Does this mean that the Type=simple examples I saw which included -d were wrong? I thought the intent of running a background service (simple or forking) is basically always to spawn a daemon?


-d (in that particular case) means “run as daemon”.

Generally it doesn’t have a specific meaning. I can mean whatever the developer of the program you’re trying to run wants it to mean.

To learn more about the different types of systemd service then you can review the official documentation. Essentially Type=forking is required for programs which fork themselves during the startup process.