Search code examples
linuxserviceoperating-systembackground-process

Difference between a service and a process which is running in a background by & command


I'm a student in CS who recently became a big fan of Linux.

I found out that there are two types of ways running a process in a background.

First, a user explicitly start a process in a shell with & command.

./main &

Second, the processes which are found by service --status-all command.

service --status-all

In my case, I can find there are 'bluetooth', 'redis-server', 'mosquitto', ...

I think they are the same in that both are running in a background.

But I want to know more accurate and detailed difference between them if any.


Solution

  • The first is started on your local term and "pushed" on background. You can see it with the jobs command. Pushing in forground with fg command for example. The first command was killed when you close your current term.

    The second is a daemon, not assingned to a terminal. It run every time