You don’t have to be a programmer to have to deal with environment variables.. It may be, for example, that when installing or configuring a program for Windows you have found a path that, instead of following the typical structure “C: / Users / Myself / folder” show something like “% USERPROFILE% / folder”.
That is because % USERPROFILE% is a environment variable: that is, a text string that operating systems such as Windows, Linux or Mac use to store values that can vary from one computer to another – or, as in this case, from one user to another – but that, nevertheless, need a unified way of accessing it.
TOP APPS WINDOWS 2020 FREE The 17 BEST PROGRAMS for your PC
Explain it to me more slowly
Typically these values refer to common system files, directories and functions whose specific path may vary, but what other programs need to be able to know.
The above example allows a program know how to access your user folder even if you have not indicated its name. Or even if he doesn’t know what version of Windows you are using (remember that the ‘C: Users ‘ Windows 10 was ‘C: Document and Settings ‘ in Windows XP).
It does not matter, because all this information is defined in the environment variables, guaranteeing that all Windows programs can do their job correctly on any computer. Because there are many more environment variables besides % USERPROFILE%. Let’s see some:
% APPDATA% – It refers to the hidden folder for program data, inside the user folder. In Windows 10 the default path is * “C: Users Username AppData Roaming”.
% COMMONPROGRAMFILES% – It refers to the folder where the programs store common files. In Windows 10 the default path is “C: Program Files Common Files”.
% PROGRAMFILES% – It refers to the folder where the programs are installed. In Windows 10 the default path is “C: Program Files”.
% WINDIR% – It refers to the folder where Windows is installed. In Windows 10 the default path is “C: Windows”.
But environment variables are not always equivalent to directory paths: they can refer to other kinds of information. A) Yes, % TIME% returns the current system time, %YOU% the version of the operating system and % PATHEXT% the list of file extensions considered executable (the common is that the list includes, in addition to the .EXE, files such as .BAT, .COM, .CMD, .JS., .JSE, .MSC, .VBE,. VBS, .WSF, .WSH, etc).
But perhaps the environment variable that we will most often have to deal with will be % PATH%. And what is its function? Have you noticed that when you type a Windows command (for example, Regedit) no need to type the full path of the executable?
That is because, every time we type a command, the system checks the folders contained in the variable % PATH% to check if any executable file matches the same.
It is a widely used resource, for example, by developers who want to call an interpreter or compiler from the project folder they are working on; many IDEs also use % PATH% to run those tools.
Check and edit our environment variables in Windows
If you want to check if the values of these variables on your computer match those shown here, you can open a command line window (CMD, not the Power Shell) and type “THREW OUT” followed by the variable in question. If you prefer to list all the variables and their respective values, go (now yes) to the Power Shell and type “Get-ChildItem Env:”.
But if you don’t like to use the command line, there is another tool that will allow us not only to check the value of each variable, but also to edit them very easily. We just have to enter ‘Advanced system settings’ in ‘Search’, and open “Environment variables” in the window that appears. And something similar to this will appear:
Once we get to this point, we will only have to select the variable that we are interested in changing and click on “Avoid”. We can also add new variables or delete them.
Command variables in Linux
In the case of Linux, the role of environment variables is the same as in Windows, although we will not find exactly the same or with the same names.
In this operating system, we must resort to command ‘printenv’ to display both the complete list of variables as the value of each of them individually.
Thus, in Linux we find variables like ‘SHELL’ (shell that will interpret the commands, in most distributions it will be Bash), ‘LANG’ (current language) or ‘HOME’ (current user’s home directory).
To change its values, we will have to resort to editing, mainly, three text files:
“/ etc / environment” – For independent variables of the command interpreter.
“etc / profile” – The variables that we define here will be valid for all interactive shells that require login. Its equivalent if we want to define only user variables is ~ / .bash_profile.
“/etc/bash.bashrc” – Same as above, but for no-login shells. Its equivalent if we want to define only user variables is ~ / .bashrc.
Disney + is here: try it free for 7 days. Afterwards, 6.99 euros per month or 69.99 euros for the annual subscription.