Adjust default PATH variable – GNU/Linux.ch

Mon, February 13, 2023, Lioh Möller

Under Linux, the PATH variable determines the paths under which to search for executable programs.

This can be set in different places. The file is ideal for system-wide configuration /etc/login.defs an.

In the following example, we assume that the PATH variable should be extended with the following path: /opt/puppetlabs/bin – this can be adjusted to personal needs.

Sea man 1 histhere are the following configuration options:

ENV_PATH (string)
    Defines the PATH environment variable for a regular user. The default value is /usr/local/bin:/bin:/usr/bin.

ENV_ROOTPATH (string), ENV_SUPATH (string)
    Defines the PATH environment variable for root. ENV_SUPATH takes precedence. The default value is /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin.

This results in the corresponding configuration:

ENV_PATH        /usr/local/bin:/bin:/usr/bin:/opt/puppetlabs/bin
ENV_SUPATH      /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/puppetlabs/bin
ENV_ROOTPATH    /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/puppetlabs/bin

In this example, PATH is used for regular user accounts, for the root user, and while gaining root privileges using are – set.

However, should sudo be used, for example by calling sudo bash, the configuration is done within sudo. The sudo configuration can be done using visado be adjusted and the corresponding parameter is as follows:

Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/puppetlabs/bin"

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.