Using Windows or Linux comes with its own knowledge. Sometimes is really difficult to switch working to the other OS. That's why I've made my walk-through to ease this transition. If you find something wrong or incomplete please comment below and I'll fix it.
The table below and the previous one: Windows cmd vs Linux shell commands are part of my Lab Diary, which I intend to post on pages on these blog and site. It contains more than 5000 articles, code snippets, best practices and my experience in IT world.
Windows - Linux equivalent variables table
Variable/Command |
Windows |
Example |
Linux |
Example2 |
Explanation |
TEMP |
%TEMP% |
C:\WINDOWS\Temp |
$TMPDIR |
/tmp |
What
directory is used as tempory folder for program
data. |
PATH |
%PATH% |
C:\Windows\ |
$PATH |
All
directories that the system will check when looking for commands. |
|
User home |
%USERPROFILE% |
C:\Users\user |
$HOME |
/home/user |
The current
user's home directory. |
USER |
%USERNAME% |
$USER |
user |
The current
logged in user. |
|
User id |
wmic useraccount get name,sid |
S-1-5-21… |
$UID |
1 |
The UID
of user. |
Current
folder |
CD |
C:\Users\user |
$PWD |
/home/user |
The current
working folder. |
Application
data |
%APPDATA% |
C:\Users\{username}\AppData\Roaming |
/home/user/.<application>/profiles/ |
Application
data folder |
|
Domain |
%USERDOMAIN% |
domain |
HOSTNAME |
domain |
The
hostname of the computer. |
Operating
System |
%OS% |
Windows_NT |
uname -a |
Linux localhost
3.11. |
The OS
version |
Languages get environmental variables table
Language |
What |
Code |
result |
python |
Get variable |
import os |
C:\Users\user' - windows |
python |
Get all |
import os |
{'TMP': 'C:\\Users\..' |
python |
Get all formatted |
import os |
('Var: ', 'OS', 'Value: ', 'Windows_NT') |
python |
Set variable |
import os |
|
java |
Get variable |
System.getenv("HOME"); |
C:\Users\user - windows |
java |
Get all |
System.getenv(); |
{TEMP="C:\Users..} |
java |
Get all formatted |
Map<String, String> var = System.getenv(); |
|
node.js |
Get variable |
process.env.HOME; |
|
node.js |
Set variable |
process.env.VAR = "value"; |
|
C# |
Get variable |
System.Environment.GetEnvironmentVariable ("HOME") |
|
C# |
Set variable |
System.Environment.SetEnvironmentVariable("VAR", "val") |
|
C |
Get variable |
value = getenv
("HOME"); |
|
C |
Set variable |
setenv ("VAR", "value", 0); |
Python get set env variables
import os
print os.environ['HOME']
print os.environ
for var in os.environ:
print('Var: ', var, 'Value: ', os.getenv(var))
os.environ['VAR'] = str(value)
os.environ['VAR'] = value
Java get set env variables
System.getenv("HOME");
System.getenv();
Map<String, String> var = System.getenv();
for (String varName : var.keySet()) {
System.out.format(""%s=%s%n"", varName, var.get(varName));
}
Node.JS get set env variables
process.env.HOME;
process.env.VAR = "value";
C# get set env variables
System.Environment.GetEnvironmentVariable ("HOME")
System.Environment.SetEnvironmentVariable("VAR", "val")
C get set env variables
value = getenv ("HOME");
setenv ("VAR", "value", 0);