Search code examples
linuxrootdevelopment-environmentsudo

Is it a good practice to always use 'root' user in development environment?


There are three options when doing software development in a Linux environment:

  1. Using your own user (e.g. mahdi)
  2. Using root
  3. Using nobody

I normally do all my development as 'root' but is it a best practice?


Solution

  • There are plenty of reasons to not use root for general usage in Linux. Barring that: Using root in a development environment will cause headaches if you are not far removed from deployment. In my opinion (and practice) development should mimic production as closely as possible. Doing development in super-user permissions is usually very different than how the software will be run (as a web user, privileged user, etc).

    This will hide things and cause issues further down the line.

    Take an example: in your code you read/write a temporary file in /opt. This works great in dev, tests pass, everything is great. The code goes out to production. /optis owned by root:root with 700 in production and the application runs as apache. The reading/writing will fail.