Environment variables are system-wide variables which share the same value. These variables are often parsed by the shell when executing commands, and are expanded into their appropriate variable. For example, this allows users to move file locations without needing to update hard-coded paths in ...

learn more… | top users | synonyms

136
votes
7answers
149k views

What are PATH and other environment variables, and how can I set or use them?

Questions about setting environment variables the PATH are very common here, and in most cases the answers are very similar to each other. In the future it would be nice to have a good Q/A for ...
71
votes
4answers
158k views

How can I display the contents of an environment variable from the command prompt in Windows 7?

In Windows 7, when I start the Command prompt, is there any command to display the contents of an environment variable (such as the JAVA_HOME or PATH variables)? I have tried with echo $PATH, echo ...
63
votes
6answers
2k views

Choosing between .bashrc, .profile, .bash_profile, etc [duplicate]

This is embarrassing, but after many years of using POSIX systems full time, I still have a hard time figuring out if a shell customization should go in .bashrc, .profile, or somewhere else. Not to ...
53
votes
4answers
60k views

Change environment variables as standard user (Windows 7)

When clicking on "Advanced system settings", I need to login as the administrator and hence only edit the administrators environment variables (in addition to the machine wide ones). How do I edit the ...
44
votes
1answer
78k views

Setting and getting windows environment variables from the command prompt?

This is a very basic question, but I can't find an answer. I want to set an environment variable from the command prompt and then be able to access it globally (for instance, I should see it by going ...
43
votes
1answer
36k views

How to reload /etc/environment without rebooting?

/etc/environment is officially the correct place for system wide environment variables. But how can I reload the assignments in this file without rebooting or relogging? Interestingly enough google ...
35
votes
4answers
42k views

Is there a list of Windows special directories/shortcuts (like %TEMP%)?

I'm looking for a reference list of shortcuts like %TEMP%. When I'm using Windows+R or Windows Explorer and type %temp%, the Windows Explorer takes me to the Temp directory. Are there more of these ...
30
votes
2answers
5k views

'less' command clearing screen upon exit - how to switch it off?

How to force the less program to not clear the screen upon exit? I'd like it to behave like git log command: it leaves the recently seen page on screen upon exiting it does not exit the less even ...
23
votes
4answers
2k views

Difference between “a=b” and “export a=b” in bash

What's the difference between: a=b and export a=b In bash? I understand that they both define environment variables, but I don't fully understand the difference.
23
votes
3answers
41k views

How do I make sudo preserve my environment variables?

Using sudo 1.7.4p4 on Solaris 5.10 and sudo 1.6.7p5 on RHEL4 u6 I can't see how to preserve my environment variables, for instance $PYTHONPATH. I've added this line to sudoers, but it doesn't make any ...
20
votes
4answers
17k views

Overriding HOMEDRIVE and HOMEPATH as a Windows 7 user

My employer has an Active Directory group policy which sets my Windows 7 laptop HOMEDRIVE to "M:" (a mapped network drive) and my HOMEPATH to "\". Since I have read-only permissions for the root of ...
16
votes
13answers
25k views

Why can't Windows handle an environment variable in Path?

My colleague and I have identical Dell workstations with Windows XP Professional x64 edition installed. My Path environment variable starts with: %JAVA_HOME%\bin;... My colleague's Path variable ...
16
votes
2answers
24k views

Can I change the PATH environmental variable in Windows 7 without restarting?

Is there anyway to change the PATH environment variable (or variables in general) on Windows 7 Exterprise (64 bit) and have it take effect in PowerShell or the command prompt (cmd.exe) without ...
14
votes
9answers
5k views

Is there any command line tool that can be used to edit environment variables in Windows?

Is there any command line tool that can be used to edit environment variables in Windows? It would be nice if this was smart tool, for example: When adding some path to let's say the PATH variable ...
14
votes
2answers
15k views

Environment variables in bash_profile or bashrc?

I have found this question [blog]: Difference between .bashrc and .bash_profile very useful but after seeing the most voted answer (very good by the way) I have further questions. Towards the end of ...
13
votes
4answers
10k views

Setting $HOME in PowerShell

How do I change my default home directory to "C:\Users\khornsby" for every time I open powershell? I am running Windows 7. Below is info about the state of my environment. Windows PowerShell ...
13
votes
2answers
11k views

How to extract environment variables from system restore point, Windows 7 64-bit

Recently a (badly written) piece of software erased my PATH variable. I've been installing software for years and recovering every single entry would be cumbersome. An even more cumbersome solution ...
12
votes
3answers
15k views

How do I see a list of all currently defined environment variables in a Linux bash terminal?

In a Linux bash terminal, there are often many environment variables that have been set, like $PATH and $HOME. Is it possible to see all of the environment variables that have been set? How?
12
votes
4answers
10k views

Overcoming the 1024 character limit with setx

I am trying to set environment variables using the setx command, such as follows setx PATH "f:\common tools\git\bin;f:\common tools\python\app;f:\common tools\python\app\scripts;f:\common ...
12
votes
2answers
4k views

Updating screen session environment variables to reflect new graphical login?

I use linux, and I like to do all my command-line work within a single screen session, so that I can restart my graphical login and such without losing my terminals. However, when I log out and back ...
11
votes
11answers
34k views

Windows command-line: create a file with the current date in its name

I'm trying to create a zip file from a batch script. I need it to be named like archive_.zip Unfortunately, this doesn't work on systems with the date formatted like y/m/d because of the slashes: ...
10
votes
1answer
5k views

How can I set environment variables for GUI apps in OS X Mavericks?

I've been struggling to get an app to run in OS X Mavericks. I finally was able to get it to run by drilling into the .app bundle and running the shell script directly. It seems that JAVA_HOME needed ...
10
votes
5answers
6k views

Adding an .exe to default path without adding the directory

For example, I want to add notepad++ to my PATH, however the directory also contains uninstall.exe and several other files/executables and I don't want them to "pollute" my path. Can I just add the ...
10
votes
1answer
7k views

How can I set environment variables for a remote rsync process?

When I use rsync to copy files from one computer to another, an rsync process is started on both ends. However, on the remote end, shell initialization files are apparently not read, so I cannot set ...
10
votes
1answer
10k views

How can I permanently append an entry into the system's PATH variable, via command line?

What I need to do: Append a folder to the %PATH% environment variable at the SYSTEM level. Make the change permanent. How I need to do it: Using the command prompt, or another method by which ...
9
votes
8answers
5k views

$PATH in Vim doesn't match Terminal

I'm using MacVim and when I don't launch it from the Terminal (mvim) its $PATH does not include what I have set in my .bash_profile. It only seems to have the default values, ...
9
votes
4answers
67k views

Easier way to change environment variables in Windows 8? [duplicate]

Possible Duplicate: What are PATH and other environment variables, and how can I set or use them? I know that I can edit my environment variables in windows 8 by going to Start -> All ...
9
votes
5answers
40k views

Different PATH environment variable for 32bit and 64bit Windows - is it possible?

Is it possible to have whole or part of PATH environment variable specific to the type of running process's image (32bit/64bit)? When I run some app from within 64bit cmd.exe I would like to have it ...
9
votes
4answers
8k views

How do I set an environmental variable for a GNOME session?

On my system, for apps that use SDL, I need to set an environmental variable: export SDL_AUDIODRIVER=alsa to get the sound to work properly. How do I set up my GNOME session so that this variable ...
9
votes
1answer
16k views

Windows 7 - User-specific %PATH%

I'd like to set up a system for Windows 7 where each user has their own private directory in %PATH%. I tried setting %PATH% to %HOMEDRIVE%%HOMEPATH%\Bin;%SystemRoot%\System32;[...] but it doesn't ...
8
votes
2answers
733 views

How do I make a batch file be able to run on other computers

When I create a batch file on my computer to execute start c:\Users\________\Whatever\..., it works on my machine. How can I get it to work on someone else's machine, since their username isn't my ...
8
votes
2answers
5k views

.profile or .bash_profile

I'm confused, where do I set environmental variables? In .profile or in .bash_profile? I am using both mac osx and ubuntu. Confused as to which one I use here.
8
votes
4answers
6k views

Setting Linux environment variables

I am running Red Hat Linux Enterprise 5; I am always using the export command to set environment variables. Are there any other ways to set environment variables and what are the ...
8
votes
2answers
6k views

Is it possible to “declare” a windows cmd-file (batch-file) as 32 bit?

Background: We do quite some scripting and little helpers with batch files (xyz.cmd) at work. Windows 7 is only now starting to become widespread here, and obviously, we hit the problems associated ...
8
votes
2answers
11k views

How can I set user environmental variables (such as PATH) from a non-administrator account on Windows 7

How can I set user environmental variables (such as PATH) from a non-administrator account on Windows 7? On Windows XP I could go into the Advanced Settings in the System Control panel. However, on ...
8
votes
4answers
2k views

Finding IP or hostname of origin machine (ssh)

I connect to a number of machines constantly, from different physical locations (and thus different physical machines). Most of this is done though ssh, sometimes a gateway machine or two is required ...
8
votes
4answers
4k views

Why won't my Windows 8 Command line update its path

I needed to add a new entry to my PATH variable. This is a common activity for me in my job, but I've recently started using Windows 8. I assumed the process would be similar to Windows 7, Vista, ...
8
votes
2answers
5k views

Cannot resolve %windir% / Cannot modify %path% or %path% being reset on boot

See Updates 3 and 4 below for how the issue has evolved My computer (Windows 7 x64, Lenovo Thinkpad T530) is having an issue resolving %windir%. After boot-up, everything works fine. At some ...
7
votes
7answers
19k views

Setting or modifying a (system wide) environment variable in cmd.exe

I am looking for a convenient way to add and/or modify and/or delete an environment variable from the command line. Particularly, I find myself at times in situations when I have to add a few ...
7
votes
3answers
21k views

Where do I set DYLD_LIBRARY_PATH on Mac OS X, and is it a good idea?

I am trying to install a solver written in C++ on my Mac (OS X), for use with code I have written in XCode. The solver documentation says this: Be sure to have "." in your DYLD_LIBRARY_PATH in ...
7
votes
5answers
4k views

Setting environment variables in OS X for GUI applications

How does one set up environment variables in Mac OS X such that they are available for GUI applications without using ~/.MacOSX/environment.plist or Login Hooks (since these are deprecated)?
7
votes
3answers
7k views

adding PATH with SETX or PATHMAN or something else?

I am trying to add a PATH from command line, as with SETX %PATH%... it always expands the PATH, which I don't want. PATHMAN is exactly for this purpose, but it doesn't work for me on Windows 7. It ...
7
votes
3answers
398 views

What is the simplest scriptable way to check whether a shell variable is exported?

For some shell sessions I want to be able to print a warning flag if a shell variable is not set and exported. It is fairly simple to do something like this to print "Error" in the prompt if SET_ME ...
7
votes
2answers
4k views

Why do I have three My Documents folders?

I'm trying to fix my profile on Windows 7. Currently %USERPROFILE% points to C:\Users\myUsername My Documents is also at C:\Users\myUsername \\profileServer\profiles$\myUsername has TWO "My ...
6
votes
3answers
313 views

Is the HOME environment variable normally set in Windows?

To be clear, I'm not asking can it be set or how to set it, I'm asking is it already set at all on a new copy of Windows. The ideal way to find this out would be to install a fresh copy of Windows on ...
6
votes
2answers
2k views

cron can't read PYTHONPATH environment variables?

I have added to the PYTHONPATH on my server's .bash_profile file. However it appears that cron isn't reading from it because I am getting import errors. If I run the exact command cron calls on the ...
6
votes
1answer
12k views

Set Permanent Environmental Variable in Windows XP

I want to set environmental variables permanently through a batch file. Is there a command to set Permanent Environmental Variable (other than SETX) for Windows XP service pack 3? command SETX ...
6
votes
4answers
166 views

Unexpected behavior in Bash

From man bash: A simple command is a sequence of optional variable assignments followed by blank-separated words and redirections, and terminated by a control operator. The first word specifies the ...
6
votes
1answer
13k views

HOSTNAME environment variable on Linux

On my Linux box (Gentoo Linux 2.6.31 to be specific) I have noticed that the HOSTNAME environment variable is available in my shell, but not in scripts. For example, $ echo $HOSTNAME returns ...
6
votes
2answers
8k views

How do I append user-defined environment variables to the system variable PATH in Windows 7?

I have two user defined variables: ANT_HOME set to %USERPROFILE%\Developer\Tools\Apache\Apache Ant\apache-ant-1.8.2 JAVA_HOME set to C:\Program Files\Java\jdk1.6.0_23 And I want append ...