This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Namespace Linux

Overview of the Bash Tools Framework functions and namespaces in the src/Linux directory

Articles in this section

TitleDescriptionUpdated
Namespace src/Linux/AptDocumentation for src/Linux/Apt directory2026-03-08
Namespace src/Linux/SudoDocumentation for src/Linux/Sudo directory2026-03-08
Namespace src/Linux/WslDocumentation for src/Linux/Wsl directory2026-03-08

1 - Namespace src/Linux/Apt

Documentation for src/Linux/Apt directory

src/Linux/Apt

Overview

Directory src/Linux/Apt

file source src/Linux/Apt/addRepository.sh

Linux::Apt::addRepository

Featuring Retry::default

add apt repository followed by an apt-get update

Environment variables
  • SKIP_APT_GET_UPDATE
Output on stdout
  • diagnostics logs
Requires
  • Linux::requireUbuntu
Features
  • Retry::default

src/Linux/Apt/install.sh

file source src/Linux/Apt/install.sh

Linux::Apt::install

Featuring Retry::default

apt-get install

Arguments
  • (softwares:String[]): list of softwares to install
Output on stdout
  • diagnostics logs
Requires
  • Linux::requireUbuntu
Features
  • Retry::default

src/Linux/Apt/installIfNecessary.sh

file source src/Linux/Apt/installIfNecessary.sh

Linux::Apt::installIfNecessary

Featuring Retry::default

apt-get install if package is not installed yet

Arguments
  • (packages:String[]): list of packages to install
Environment variables
  • SKIP_APT_GET_UPDATE
Output on stdout
  • diagnostics logs
Requires
  • Linux::requireUbuntu
Features
  • Retry::default

src/Linux/Apt/isPackageInstalled.sh

file source src/Linux/Apt/isPackageInstalled.sh

Linux::Apt::isPackageInstalled

check if apt package is installed

Arguments
  • $1 (package:String): the package name to check
Output on stdout
  • diagnostics logs
Requires
  • Linux::requireUbuntu

src/Linux/Apt/remove.sh

file source src/Linux/Apt/remove.sh

Linux::Apt::remove

Featuring Retry::default

remove ubuntu packages

Arguments
  • (softwares:String[]): list of softwares to remove
Output on stdout
  • diagnostics logs
Requires
  • Linux::requireUbuntu
Features
  • Retry::default

src/Linux/Apt/repositoryExists.sh

file source src/Linux/Apt/repositoryExists.sh

Linux::Apt::repositoryExists

check if apt repository is added to apt sources Linux::requireSudoCommand

Output on stdout
  • diagnostics logs
Requires
  • Linux::requireUbuntu

src/Linux/Apt/update.sh

file source src/Linux/Apt/update.sh

Linux::Apt::update

Featuring Retry::default

update apt packages list

Output on stdout
  • diagnostics logs
Requires
  • Linux::requireUbuntu
Features
  • Retry::default

2 - Namespace src/Linux/Sudo

Documentation for src/Linux/Sudo directory

src/Linux/Sudo

Overview

Directory src/Linux/Sudo

file source src/Linux/Sudo/asUser.sh

Linux::Sudo::asUser

execute command passed as arguments using sudo if current user is not already the targeted user

Arguments
  • (args:String[]): the command to execute as sudo
Environment variables
  • USERNAME (String): sudo as this user (root by default)
Exit codes
  • 1: exit code of command
Requires
  • Linux::requireSudoCommand

src/Linux/Sudo/asUserInheritEnv.sh

file source src/Linux/Sudo/asUserInheritEnv.sh

Linux::Sudo::asUserInheritEnv

execute command passed as arguments using sudo with environment inherited if current user is not already the targeted user

Arguments
  • (args:String[]): the command to execute as sudo
Environment variables
  • USERNAME (String): sudo as this user (root by default)
Exit codes
  • 1: exit code of sudo command
Requires
  • Linux::requireSudoCommand

3 - Namespace src/Linux/Wsl

Documentation for src/Linux/Wsl directory

src/Linux/Wsl

Overview

Directory src/Linux/Wsl

file source src/Linux/Wsl/assertWindowsEtcHost.sh

Linux::Wsl::assertWindowsEtcHost

Check if Host is defined in etc/hosts of windows

Arguments
  • $1 host:String
Exit codes
  • 1: if hostname not found

src/Linux/Wsl/cachedWslpath.sh

file source src/Linux/Wsl/cachedWslpath.sh

Linux::Wsl::cachedWslpath

Deprecated use Linux::Wsl::cachedWslpath2 instead Featuring cache

retrieve wslpath using cache (cache is refreshed every day)

Arguments
  • (args:String[]): arguments to pass to wslpath
Environment variables
  • WSL_TMPDIR (String): temp directory to store the wslpath cache (default value: TMPDIR), you can use PERSISTENT_TMPDIR instead
Exit codes
    • if Linux::Wsl::originalWslpath cannot find the path
Output on stderr
  • diagnostics information is displayed
Requires
  • Linux::Wsl::requireWsl
Features
  • cache

src/Linux/Wsl/cachedWslpath2.sh

file source src/Linux/Wsl/cachedWslpath2.sh

Linux::Wsl::cachedWslpath2

Featuring cache

retrieve wslpath using cache (cache is refreshed every day)

Arguments
  • (args:String[]): arguments to pass to wslpath
Environment variables
  • WSL_TMPDIR (String): temp directory to store the wslpath cache (default value: PERSISTENT_TMPDIR), you can use TMPDIR instead
Exit codes
    • if Linux::Wsl::originalWslpath cannot find the path
Output on stderr
  • diagnostics information is displayed
Requires
  • Linux::Wsl::requireWsl
Features
  • cache

src/Linux/Wsl/cachedWslpathFromWslVar.sh

file source src/Linux/Wsl/cachedWslpathFromWslVar.sh

Linux::Wsl::cachedWslpathFromWslVar

Deprecated use Linux::Wsl::cachedWslpathFromWslVar2 instead Featuring cache

retrieve path from wslvar and then use wslpath to resolve it using cache (cache is refreshed every day)

Arguments
  • $1 (var:String): the var to retrieve using wslvar
  • (args:String[]): (optional) additional arguments to pass to wslvar
Environment variables
  • WSL_TMPDIR (String): temp directory to store the wslpath cache (default value: TMPDIR), you can use PERSISTENT_TMPDIR instead
Exit codes
    • if Linux::Wsl::originalWslpath cannot find the path or Linux::Wsl::originalWslvar cannot find the var
Output on stderr
  • diagnostics information is displayed
Requires
  • Linux::Wsl::requireWsl
Features
  • cache

src/Linux/Wsl/cachedWslpathFromWslVar2.sh

file source src/Linux/Wsl/cachedWslpathFromWslVar2.sh

Linux::Wsl::cachedWslpathFromWslVar2

Featuring cache

retrieve path from wslvar and then use wslpath to resolve it using cache (cache is refreshed every day)

Arguments
  • $1 (var:String): the var to retrieve using wslvar
  • (args:String[]): (optional) additional arguments to pass to wslvar
Environment variables
  • WSL_TMPDIR (String): temp directory to store the wslpath cache (default value: PERSISTENT_TMPDIR), you can use TMPDIR instead
Exit codes
  • 1: if var cannot be found in cache nor using Linux::Wsl::originalWslvar
  • 2: if path cannot be found in cache nor using Linux::Wsl::originalWslpath
Output on stderr
  • diagnostics information is displayed
Requires
  • Linux::Wsl::requireWsl
Features
  • cache

src/Linux/Wsl/cachedWslvar.sh

file source src/Linux/Wsl/cachedWslvar.sh

Linux::Wsl::cachedWslvar

Deprecated use Linux::Wsl::cachedWslvar2 instead Featuring cache

retrieve wslvar using cache (cache is refreshed every day)

Arguments
  • (args:String[]): arguments to pass to wslvar
Environment variables
  • WSL_TMPDIR (String): temp directory to store the wslvar cache (default value: TMPDIR), you can use PERSISTENT_TMPDIR instead
Exit codes
    • if Linux::Wsl::originalWslvar cannot find the variable
Output on stderr
  • diagnostics information is displayed
Requires
  • Linux::Wsl::requireWsl
Features
  • cache

src/Linux/Wsl/cachedWslvar2.sh

file source src/Linux/Wsl/cachedWslvar2.sh

Linux::Wsl::cachedWslvar2

Featuring cache

retrieve wslvar using cache (cache is refreshed every day)

Arguments
  • $1 (cachedWslvar2_var:&String): the variable to set by reference if the value is found
  • (args:String[]): arguments to pass to wslvar
Environment variables
  • WSL_TMPDIR (String): temp directory to store the wslvar cache (default value: PERSISTENT_TMPDIR), you can use TMPDIR instead
Exit codes
    • if Linux::Wsl::originalWslvar cannot find the variable
Output on stderr
  • diagnostics information is displayed
Requires
  • Linux::Wsl::requireWsl
Features
  • cache

src/Linux/Wsl/initEnv.sh

file source src/Linux/Wsl/getKeyFromWslpathOptions.sh

Linux::Wsl::initEnv

Featuring cache 1 Warning(s)

initialize some important variables for scripts to run correctly when wsl installation is run under wsl is in progress

Function has no arguments.

Environment variables
  • WSL_INIT (int): 0 to disable wsl env initialization
Variables set
  • PATH (String): populated with WINDOW_PATH paths
  • WSL_INTEROP (String): with current used process
  • WSL_DISTRO_NAME (String): initialized using wslpath -m /
Output on stderr
  • diagnostics information is displayed
Requires
  • Linux::Wsl::requireWsl
Features
  • cache
Warnings
  • initialization skipped if script not run under wsl

src/Linux/Wsl/originalWslpath.sh

file source src/Linux/Wsl/originalWslpath.sh

Linux::Wsl::originalWslpath

call simply original wslpath command

Arguments
  • (args:String[]): args to pass to wslpath
Exit codes
    • wslpath exit code
Output on stdout
  • wslpath stdout
Requires
  • Linux::Wsl::requireWsl

src/Linux/Wsl/originalWslvar.sh

file source src/Linux/Wsl/originalWslvar.sh

Linux::Wsl::originalWslvar

call simply original wslvar command

Arguments
  • (args:String[]): args to pass to wslvar
Exit codes
    • wslvar exit code
Output on stdout
  • wslvar stdout
Requires
  • Linux::Wsl::requireWsl

src/Linux/Wsl/requireWsl.sh

file source src/Linux/Wsl/requireWsl.sh

Linux::Wsl::requireWsl

ensure linux runs under wsl

Environment variables
  • WSL_GARBAGE_COLLECT (int): 0 to disable garbage collect of cache files
Exit codes
  • 1: if linux does not run under wsl