On some workstations (Debian & Ubuntu) and on a server (CentOS) I need environment variables for some scripts and jobs. What I did was altering ~/.profile:


Is this common practice? Are there any side effects I need to know about? Or is this solution fine & stable? Especially on the server I need this to work reliably.

I used ~/.profile because the scripts are always executed via job-specific users without sudo rights - so I thought user-specific environment variables would be appropriate?!


Since the paths differ on the machines and we're talking about more than one or two variables passing the variables as parameters to the scripts wouldn't be a nice solution and hardcoding them into the scrips would require me to update it manually for every machine. That's why I wanted environment variables.

  • Why not setting those variables directly in the script or giving the parameters as command line options?
    – michas
    Feb 13, 2016 at 12:25
  • Because the paths they model are different on some of the workstations and especially on the server. So I want to read the variables in the script - otherwise I would have to manually put them in the scripts each time I have to change something (for every machine).
    – daniel451
    Feb 13, 2016 at 12:26

1 Answer 1


It is possible to do so, and I use it to change the default of some programs (usually in form of my default parameters).

For scripts I write I prefer to put the configuration in a separate file ~/.my_program_x.conf and do a . ~/.my_program_x.conf.

In general (AFAIK) scripts prefer to have a configuration file for such cases.

Note: I think you should prefix the variables with export, or some scripts could not see the variable.

You must log in to answer this question.

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