LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-09-2017, 06:18 PM   #1
linux_new_user000
LQ Newbie
 
Registered: Jan 2017
Posts: 1

Rep: Reputation: Disabled
Environment_Variable_Setting


Hi everyone,

I am almost new linux user and I have a question if anyone can help me. I have installed a software on my computer, and on the README the last step is written :

"Set the following environment variables to indicate where the program files can
be found:

GULP_LIB The location of the Libraries directory
GULP_DOC The location of the Doc directory "
I don't know how to do that and I appreciate if anyone can help me.
 
Old 01-09-2017, 11:53 PM   #2
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Hi, and welcome. If you search on the web for "linux set environment variables", you will find many articles on how to set environment variables.

The key thing you need to do is to to ensure that the relevant environment variables are permanently set each time you boot into Linux so that you don't have to do it each time (search for "linux permanently set environment variables").
 
1 members found this post helpful.
Old 01-10-2017, 03:07 AM   #3
aragorn2101
Member
 
Registered: Dec 2012
Location: Mauritius
Distribution: Slackware
Posts: 567

Rep: Reputation: 301Reputation: 301Reputation: 301Reputation: 301
Hi,

Welcome to LQ.

Check this out: http://tldp.org/LDP/Bash-Beginners-G...ect_03_02.html

It is easy to set environment variables. You just export them. e.g.
Code:
> export TMPLIBPATH=/usr/local/lib
> echo $TMPLIBPATH
/usr/local/lib
But you'll see that if you close the terminal or restart your computer, the variable will no longer be there. In order to have the variable set automatically everytime you start your computer or start a new terminal session, then you should add the export commands to your /etc/bashrc for system-wide change or to your local /home/USERNAME/.bashrc file.
 
1 members found this post helpful.
Old 01-10-2017, 11:48 AM   #4
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
If you have a directory /etc/profile.d you can add or edit an existing file that sets environment variables whenever you log in. Of course, if you don't have that directory you need to do something different.

The way environment variables are set begins with /etc/profile (no matter what shell you're using; e.g., BASH, C-Shell, KornShell, whatever-shell). The content of /etc/profile is the first configuration and environment setting that occurs. Generally, you do not want to edit or add anything in /etc/profile; it's better to modify or add settings somewhere else; that's the purpose of small scripts found in /etc/profile.d.

For example, I use KornShell system-wide for all users (the functionality of BASH is KornShell and most BASH shell programs will run just fine in KornShell and vice versa).

The file /etc/profile.d/ksh (which I add to the system) looks like this:
Code:
cat /etc/profile.d/ksh.sh
#!/bin/sh
#ident	"$Id$"
#
#	Name:		$Source$
#	Version:	$Revision$
#	Modified:	$Date$
#	Purpose:	set local environment variables for Korn Shell
#	Author:		T. N. Ronayne
#	Date:		1 Oct 2009
#	$Log$
# Set the HOST environment variable
export HOST="`uname -n`"
# Set ksh93 visual editing mode:
if [ "$SHELL" = "/bin/ksh" ]; then
#  VISUAL=emacs		# ugh
#  VISUAL=gmacs		# double ugh
   VISUAL=vi		# ah, elegance
fi
# Set a default shell prompt:
#PS1='`hostname`:`pwd`# '
# Do these anyway in case sombody uses a different shell
if [ "$SHELL" = "/bin/pdksh" ]; then
 PS1='! $ '
elif [ "$SHELL" = "/bin/ksh" ]; then
 PS1='${HOST}-${USER}-${PWD}: '
elif [ "$SHELL" = "/bin/zsh" ]; then
 PS1='%n@%m:%~%# '
elif [ "$SHELL" = "/bin/ash" ]; then
 PS1='$ '
else
 PS1='\u@\h:\w\$ '
fi
PS2='> '
export PS1 PS2
Those settings cause the system prompt (in a terminal window) look like this:
Code:
fubar-trona-/home/trona:
That is, the system name, the login name and the current working directory; every time I (or any other user) changes to another directory the prompt shows that directory name.

And the VISUAL environment variable is set to vi which then does command line editing with vi editing commands (move the cursor, change or replace characters and words and so on). Handy.

So, on login, the first settings are /etc/profile, the second settings are any of the files found in /etc/profile.d (including the file ksh.sh).

Finally, your environment is set by the content of .profile found in your home directory and any ".bashrc" file found in your home directory.

All the above is moot if you don't have /etc/profile.d though.

Let's say that the application you installed was done from source with configure-make-make install. The default path in one of those will be to install in /usr/local, where there should be a tree either already existing or created by the make install directive; there may be a bin, doc, etc, include, lib, lib64, man, sbin and share directories (some may not be there, say lib64, sbin, share; the application you install will have the directories needed in /usr/local.

And you application will run just fine from /usr/local. And, most systems default to adding /usr/local to your PATH environment so that things will be found.

Let's say that you install Java (which is not installed by default due to licensing). You download Java from Oracle, you install it using the instructions and you will have a file of some sort -- either in /etc/profile.d or somewhere else most likely in /etc -- that will look list this:
Code:
cat /etc/profile.d/jdk.sh 
#!/bin/sh
export JAVA_HOME=/usr/lib64/java
export MANPATH="${MANPATH}:${JAVA_HOME}/man"
export PATH="${PATH}:${JAVA_HOME}/bin:${JAVA_HOME}/jre/bin"
(I have Oracle Java and I install the JDK version -- which includes JRE -- if you only install JRE the jdk.sh file will point to its location.)

If your distribution has a software collection (that includes Java) and you install from that it is most likely that the PATH will be set for you.

One last thing: if you use terminal windows to work in, you will want to set the preferences so that the terminal is a "log-in terminal." That causes the terminal program to read all the settings as if you logged in from a cold start; you get all the environment variables set (/etc/profile, /etc/profile.d (if it exists), your [I]home/.profle/I] and your home/.basrc (or whatever) will be scanned and their content will be set.

I realize that this might be confusing -- what happens if you don't have /etc/profile.d? There will be something, somewhere in you distribution that will do the same thing or, at worse, you can create a .profile in your home directory and simply copy the examples above into it but it would be better to find out where your distribution does such things -- it'll be there somewhere and should be explained in your system documentation (somewhere).

Hope this helps some.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration