Prometheus
Prometheus

Reputation: 33655

Using .sh script to set an environment variable

How do I write an .sh script what will globally set an environment variable on Ubuntu 14.

i.e.

#!/bin/sh
sets this in to master /etc/environment 
export DB_HOST="123"

I am aware I could just run this script and it would set it for the session only!, but what I actually want to do is have the .sh script copy the environment variable to /etc/environment so it is system wide.

OR

is there a way to run the script that it gets set globally?

Upvotes: 2

Views: 1891

Answers (1)

Paul Evans
Paul Evans

Reputation: 27577

Run your script from /etc/profile, then you'll get what yuo're after.

Upvotes: 1

Related Questions