Main Content

Managing daemons from a terminal session

Archive - Originally posted on "The Horse's Mouth" - 2012-07-01 08:33:18 - Graham Ellis

If you want to manage a daemon on a Linux system, how do you do it?

• It's likely that you cannot log in directly as the dameon user, as the account will almost certainly not have a valid encoded password string, so every attempt to give a password (including just pressing "enter" when asked) would fail.

• I hope you system has been set up so that your ordinary user account can't control the daemon. It would require quite deliberate tampering with permissions, or an extraordinary user and group system, to allow this in any case.

• You could log in as root (that's provided that you have the password and access to a place from which root login is allowed), but this would be dangerous - you would have no protection against errors, and you would need to do a lot of checking and re-chowning of files.

Here's what to do:
1. Log in as your regular user
2. Use su - (note the minus sign please) to become root. You WILL need to know the root password, but you won't need to be a terminal / port that allows direct root logins
3. Use su - [dameonname] (where [daemonname] is the name of the user who runs the daemon) to become that daemon user. Since root can su to another user without giving a password, you'll become the daemon user at this point.

Note that each su command starts a subshell, so you should exit from each shell when completed - do NOT su back to your original user as you'll start to build up more and more shell layers ...

As explained on our Introduction to Linux Admin day during last week's Deploying LAMP course.