# What is the scope of environment variables defined in rc.local? [closed]

Ubuntu 14.04

Since rc.local is executed as root, does this mean that environment variables of rc.local will be available to all the processes run as root? Why?

## closed as unclear what you're asking by Christopher, jimmij, Rui F Ribeiro, X Tian, ArchemarFeb 11 at 10:24

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• On what OS? rc.local does very different things on Linux, FreeBSD, and OpenBSD. It probably does very different things on different Linux distributions. – Satō Katsura May 2 '17 at 7:32
• @SatoKatsura edited – Aquarius_Girl May 2 '17 at 8:27
• Doesn't Ubuntu 14.04 use systemd? Then rc.local is a systemd-related thing. But even assuming SysV init, environment variables set in a shell script are inherited only by programs that are descendants of said script, and only if they are export-ed. The vast majority of root processes you get to see are descendants of login and / or some X display manager, which have nothing to do with rc.local. – Satō Katsura May 2 '17 at 10:26

No, the scripts in rc.local are run as separate processes, which means they have no way to modify their parent's environment.
If you want to set environment variables system-wide, the place for that is /etc/profile.
The FreeBSD rc.local documentation mentions a convention that /etc/rc.d/ scripts whose name ends with .sh will be sourced rather than executed independently. I don't think this is portable to other platforms, though I could be wrong.