WSL ubuntu sudo keep env (WSL_DISTRO_NAME)

Linux/ubuntu

  • outline

Environment variable WSL_DISTRO_NAME does not available as root

  • before configuration
$ echo $WSL_DISTRO_NAME
Ubuntu-22.04
$ sudo -i
$ echo $WSL_DISTRO_NAME
  • configuration for sudoers env (WSL_DISTRO_NAME)
vim /etc/sudoers
Defaults        env_keep=WSL_DISTRO_NAME
  • after configuration
$ echo $WSL_DISTRO_NAME
Ubuntu-22.04
$ sudo -i
$ echo $WSL_DISTRO_NAME
Ubuntu-22.04