How to troubleshoot linux services?
Linux service is a program that runs continuously in the background and serves specific application all the time. We see lot of errors when starting Linux services, something like below
For example let us take samba service has the above issue and hit the below command for extra details.
$systemctl status smbd.service
This will show the following.
This command is just showing there is error while starting the service. To get full picture of why service is not running we have to analyze the ".service" file.
Now the samba service file is at
Cat the contents of the file(Truncated result):
[Service] EnvironmentFile=-/etc/default/samba ExecStart=/usr/sbin/smbd --foreground --no-process-group $SMBDOPTIONS
It is showing that the binary file called "smbd" will have to start with the SMBDOPTIONS. Here the main program which is running continuously as service is "smbd".
To troubleshoot the service we will directly run the same "smbd" binary.
The binary is running with the environment variables. If the values in the environment file are not accessible or corrupted then the binary throws an error. That error would be the root cause for the issue and fixing that error will make that service up and running.