I got some questions:

  • What is difference between running program as root, and running program with sudo programxxx? Is sudo more safe?
  • Do I have to run process as user? Or maybe as sudo excuteprogram?
  • So, how i run those programs: Apache, phpmyadmin ,mysql - as user? (I mean, is it good, 1 user run = one daemon, program)
  • How can I run programs as user? I can"t run apache, mysql, and others as normal user.

2 Answers 2


Sudo is "safer" because it adheres to the principal of least privilege. That is to say "only run with administrator privileges when you absolutely must"

Sudo also logs which user performs which command while running as root does not unless you have auditd enabled.

Sudo is also very configurable. You can allow a group called "web administrators" to just restart the apache or nginx process. So you can restrict the superuser/administrator privilege to just the commands a particular group needs.

Sudo also allows you to run a program as someone other than root. "sudo -u mysql " allows you to run as the user mysql. Again that can be controlled with different privileges given to different groups or people.


Running a program as root directly or through sudo has basically the same result. The use of sudo is to avoid using the root account all the time, where errors can have dramatic results.

Regarding specific program you cite, some of them must start as root initially so that they can initialize properly, for example do a binding on a privileged (<1024) port, or start automatically at boot time. Most can them shift to another user, but this is usually product dependend : see their specific documentation.

  • A process no longer needs to run as root to bind to privileged ports. Same for other privileges. see capabilities (beware a few capabilities can allow capability escalation, but is no worse that being root). Commented Oct 18, 2015 at 21:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .