Solved

Ubuntu Server Linux: I want to automatically set two environmental variables at server startup

Posted on 2007-11-29
4
802 Views
Last Modified: 2013-11-15
Is there some way for two particular environment variables to be set automatically on server startup?  (CVSROOT and CVS_RSH)

Thanks
0
Comment
Question by:oxygen_728
  • 2
4 Comments
 
LVL 34

Assisted Solution

by:Duncan Roe
Duncan Roe earned 150 total points
Comment Utility
Sure - you can put them in /etc/profile.  The all Bourne-style shell logins will get them (including bash). There's another file if you use csh.
I think you could put them in an early rc file (in /etc/rc.d, varies with distribution) then all processes will get them (because init is the ancestor of all processes). But that's not the usual way.
0
 
LVL 40

Assisted Solution

by:omarfarid
omarfarid earned 350 total points
Comment Utility
Hi,

The /etc/profile file will be read when users login to the server. If you want to run a command or tool that will need these variables, then you set then in the script that call these commands or tools.

0
 

Author Comment

by:oxygen_728
Comment Utility
Can you give me an example of what to put into /etc/profile to set the CVSROOT environment variable?

Do just throw the line "export CVSROOT=VALUE" into the file in a blank line?

Thanks for the help.

0
 
LVL 40

Accepted Solution

by:
omarfarid earned 350 total points
Comment Utility
Hi,

The /etc/profile is like the .profile file in the home dir of the user. It is read when the user is logged in and all commands in it are executed in the login shell.

So, it is as you described

But if you want to set variables for jobs / scripts that will run at startup, you need to add such statements to the scripts since the scripts do not read /etc/profile file.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Join & Write a Comment

The purpose of this article is to show how we can create Linux Mint virtual machine using Oracle Virtual Box. To install Linux Mint we have to download the ISO file from its website i.e. http://www.linuxmint.com. Once you open the link you will see …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now