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












0















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?



Please include references while answering.










share|improve this question















closed as unclear what you're asking by Christopher, jimmij, Rui F Ribeiro, X Tian, Archemar Feb 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.














  • 1





    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
















0















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?



Please include references while answering.










share|improve this question















closed as unclear what you're asking by Christopher, jimmij, Rui F Ribeiro, X Tian, Archemar Feb 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.














  • 1





    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














0












0








0








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?



Please include references while answering.










share|improve this question
















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?



Please include references while answering.







linux environment-variables






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 2 '17 at 8:27







Aquarius_Girl

















asked May 2 '17 at 5:42









Aquarius_GirlAquarius_Girl

64042141




64042141




closed as unclear what you're asking by Christopher, jimmij, Rui F Ribeiro, X Tian, Archemar Feb 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.









closed as unclear what you're asking by Christopher, jimmij, Rui F Ribeiro, X Tian, Archemar Feb 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.










  • 1





    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














  • 1





    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








1




1





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







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





@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





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










1 Answer
1






active

oldest

votes


















1














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.






share|improve this answer


























  • please point out the manual where it is mentioned that the scripts in rc.local are run as separate processes.

    – Aquarius_Girl
    May 2 '17 at 5:55











  • I don't think it's explicitly mentioned (though "scripts" should suggest this interpretation; if the files were sourced by a shell, surely that would need to be mentioned!), but quick experimentation should easily bear this out. It's also not a heavily standardized mechanism, so the precise documentation depends on your platform. The FreeBSD manual page seems pretty exhaustive: freebsd.org/cgi/man.cgi?query=rc.local&sektion=8

    – tripleee
    May 2 '17 at 5:57




















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














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.






share|improve this answer


























  • please point out the manual where it is mentioned that the scripts in rc.local are run as separate processes.

    – Aquarius_Girl
    May 2 '17 at 5:55











  • I don't think it's explicitly mentioned (though "scripts" should suggest this interpretation; if the files were sourced by a shell, surely that would need to be mentioned!), but quick experimentation should easily bear this out. It's also not a heavily standardized mechanism, so the precise documentation depends on your platform. The FreeBSD manual page seems pretty exhaustive: freebsd.org/cgi/man.cgi?query=rc.local&sektion=8

    – tripleee
    May 2 '17 at 5:57


















1














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.






share|improve this answer


























  • please point out the manual where it is mentioned that the scripts in rc.local are run as separate processes.

    – Aquarius_Girl
    May 2 '17 at 5:55











  • I don't think it's explicitly mentioned (though "scripts" should suggest this interpretation; if the files were sourced by a shell, surely that would need to be mentioned!), but quick experimentation should easily bear this out. It's also not a heavily standardized mechanism, so the precise documentation depends on your platform. The FreeBSD manual page seems pretty exhaustive: freebsd.org/cgi/man.cgi?query=rc.local&sektion=8

    – tripleee
    May 2 '17 at 5:57
















1












1








1







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.






share|improve this answer















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.







share|improve this answer














share|improve this answer



share|improve this answer








edited May 2 '17 at 6:00

























answered May 2 '17 at 5:49









tripleeetripleee

5,23311829




5,23311829













  • please point out the manual where it is mentioned that the scripts in rc.local are run as separate processes.

    – Aquarius_Girl
    May 2 '17 at 5:55











  • I don't think it's explicitly mentioned (though "scripts" should suggest this interpretation; if the files were sourced by a shell, surely that would need to be mentioned!), but quick experimentation should easily bear this out. It's also not a heavily standardized mechanism, so the precise documentation depends on your platform. The FreeBSD manual page seems pretty exhaustive: freebsd.org/cgi/man.cgi?query=rc.local&sektion=8

    – tripleee
    May 2 '17 at 5:57





















  • please point out the manual where it is mentioned that the scripts in rc.local are run as separate processes.

    – Aquarius_Girl
    May 2 '17 at 5:55











  • I don't think it's explicitly mentioned (though "scripts" should suggest this interpretation; if the files were sourced by a shell, surely that would need to be mentioned!), but quick experimentation should easily bear this out. It's also not a heavily standardized mechanism, so the precise documentation depends on your platform. The FreeBSD manual page seems pretty exhaustive: freebsd.org/cgi/man.cgi?query=rc.local&sektion=8

    – tripleee
    May 2 '17 at 5:57



















please point out the manual where it is mentioned that the scripts in rc.local are run as separate processes.

– Aquarius_Girl
May 2 '17 at 5:55





please point out the manual where it is mentioned that the scripts in rc.local are run as separate processes.

– Aquarius_Girl
May 2 '17 at 5:55













I don't think it's explicitly mentioned (though "scripts" should suggest this interpretation; if the files were sourced by a shell, surely that would need to be mentioned!), but quick experimentation should easily bear this out. It's also not a heavily standardized mechanism, so the precise documentation depends on your platform. The FreeBSD manual page seems pretty exhaustive: freebsd.org/cgi/man.cgi?query=rc.local&sektion=8

– tripleee
May 2 '17 at 5:57







I don't think it's explicitly mentioned (though "scripts" should suggest this interpretation; if the files were sourced by a shell, surely that would need to be mentioned!), but quick experimentation should easily bear this out. It's also not a heavily standardized mechanism, so the precise documentation depends on your platform. The FreeBSD manual page seems pretty exhaustive: freebsd.org/cgi/man.cgi?query=rc.local&sektion=8

– tripleee
May 2 '17 at 5:57





Popular posts from this blog

How to make a Squid Proxy server?

Is this a new Fibonacci Identity?

19世紀