0

When adding a variable in export The variable is deleted automatically upon the end of the cli session or the closing of wsl

abdalla@DESKTOP-9IC0VL5:/mnt/c/Users/hp$ export desk=/mnt/c/Users/hp/Desktop
abdalla@DESKTOP-9IC0VL5:/mnt/c/Users/hp$ echo $desk
/mnt/c/Users/hp/Desktop
abdalla@DESKTOP-9IC0VL5:/mnt/c/Users/hp$ exit 
C:\Users\hp>bash
abdalla@DESKTOP-9IC0VL5:/mnt/c/Users/hp$ echo $desk

abdalla@DESKTOP-9IC0VL5:/mnt/c/Users/hp$

Distribution used

ubuntu wsl

Notme
  • 83

1 Answers1

0

That is the normal behaviour. export makes variables available for child processes and does not save them for later or other sessions.

If you want variables available in every new session, you need to export the variables everytime you start a new session. This can be done automatically e.g. by adding the export command it to your .profile, .bash_profile or .bashrc file.

pLumo
  • 22,565