Linux mint environment variables

Linux Mint — Adding Environment Variables Permanently

Linux Mint — adding environment variables permanently

Try this in the ~/.pam_environment in your home folder. If it does not exist then create it:

PATH DEFAULT=$:/home/paul/avatar-gf-1.0-ea/glassfish4/bin/

You will need to log in and out.

How to permanently set $PATH on Linux/Unix

There are multiple ways to do it. The actual solution depends on the purpose.

The variable values are usually stored in either a list of assignments or a shell script that is run at the start of the system or user session. In case of the shell script you must use a specific shell syntax and export or set commands.

System wide

  1. /etc/environment List of unique assignments. Allows references. Perfect for adding system-wide directories like /usr/local/something/bin to PATH variable or defining JAVA_HOME . Used by PAM and systemd.
  2. /etc/environment.d/*.conf List of unique assignments. Allows references. Perfect for adding system-wide directories like /usr/local/something/bin to PATH variable or defining JAVA_HOME . The configuration can be split into multiple files, usually one per each tool (Java, Go, and Node.js). Used by systemd that by design do not pass those values to user login shells.
  3. /etc/xprofile Shell script executed while starting X Window System session. This is run for every user that logs into X Window System. It is a good choice for PATH entries that are valid for every user like /usr/local/something/bin . The file is included by other script so use POSIX shell syntax not the syntax of your user shell.
  4. /etc/profile and /etc/profile.d/* Shell script. This is a good choice for shell-only systems. Those files are read only by shells in login mode.
  5. /etc/.rc . Shell script. This is a poor choice because it is single shell specific. Used in non-login mode.
Читайте также:  File permission in linux chmod

User session

  1. ~/.pam_environment . List of unique assignments, no references allowed. Loaded by PAM at the start of every user session irrelevant if it is an X Window System session or shell. You cannot reference other variables including HOME or PATH so it has limited use. Used by PAM.
  2. ~/.xprofile Shell script. This is executed when the user logs into X Window System system. The variables defined here are visible to every X application. Perfect choice for extending PATH with values such as ~/bin or ~/go/bin or defining user specific GOPATH or NPM_HOME . The file is included by other script so use POSIX shell syntax not the syntax of your user shell. Your graphical text editor or IDE started by shortcut will see those values.
  3. ~/.profile , ~/._profile , ~/._login Shell script. It will be visible only for programs started from terminal or terminal emulator. It is a good choice for shell-only systems. Used by shells in login mode.
  4. ~/.rc . Shell script. This is a poor choice because it is single shell specific. Used by shells in non-login mode.

Notes

GNOME on Wayland starts a user login shell to get the environment. It effectively uses the login shell configurations ~/.profile , ~/._profile , ~/._login files.

Man pages

  • environment
  • environment.d https://linux.die.net/man/1/environment.d
  • bash
  • dash

Distribution-specific documentation

Difference between Login Shell and Non-Login Shell?

How to set environment variable for everyone under my linux system?

As well as /etc/profile which others have mentioned, some Linux systems now use a directory /etc/profile.d/ ; any .sh files in there will be sourced by /etc/profile . It’s slightly neater to keep your custom environment stuff in these files than to just edit /etc/profile .

Читайте также:  Error code linux bash

Change JAVA_HOME value in Linux Mint 19x

Via the command line, you can simply change your JAVA_HOME variable path:

export JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64"

Then redefine the current path prefixing the jdk binaries:

export PATH=$JAVA_HOME/bin:$PATH

NB: This will only take effect within the current terminal session.

How to set JAVA_HOME in Linux for all users

  1. find /usr/lib/jvm/java-1.x.x-openjdk
  2. vim /etc/profile Prepend sudo if logged in as not-privileged user, ie. sudo vim
  3. Press ‘i’ to get in insert mode
  4. add:
export JAVA_HOME="path that you found"

export PATH=$JAVA_HOME/bin:$PATH

How can I edit the $PATH on linux?

To permanently store your path, you have a few options.

I suggest you read the Ubuntu community wiki on Environment Variables but the short answer is the best place is ~/.profile for your per-user PATH setting or /etc/profile for global settings.

Change PATH:

export PATH=$PATH:/your/new/path/here
export PATH=:/your/new/path/here:/another/new/path/here

Источник

Linux Mint — adding environment variables permanently [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.

PATH=$PATH:/home/paul/avatar-gf-1.0-ea/glassfish4/bin/ 

at the end. I restarted the terminal, but it still did not identify commands in that directory. Does anyone know what I am doing wrong?

This is what I get if I «echo $PATH»: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/paul/jdk1.8.0/bin/

5 Answers 5

Try this in the ~/.pam_environment in your home folder. If it does not exist then create it:

PATH DEFAULT=$:/home/paul/avatar-gf-1.0-ea/glassfish4/bin/ 

You will need to log in and out.

I edited it slightly as per the Ubuntu website you should now set session variables in ~/.pam_environment see: help.ubuntu.com/community/EnvironmentVariables

Run bash -xl to see which startup files are loaded with your shell. .profile may actually not be read. Otherwise try adding export to your assignment:

export PATH=$PATH:/home/paul/avatar-gf-1.0-ea/glassfish4/bin/ 

Reference about Bash’s startup files: Bash Startup Files

I’m running Linux Mint 18.3 Cinnamon. The changes in file ~/.profile got picked up only after I logged out/in from the account. The terminal restart was not enough in my case.

Читайте также:  Linux create symlink to folder

If you edit the .bashrc file,

you will see the next line

# Alias definitions. # You may want to put all your additions into a separate file like # ~/.bash_aliases, instead of adding them here directly. # See /usr/share/doc/bash-doc/examples in the bash-doc package. if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi 

So create a ~/.bash_aliases file in your $HOME folder and add any command you want to be executed when you open the terminal.

Источник

How to Set environment variables permanently in Linux Mint

Environment variables help programs to find important information and work properly. For example Java programs use JAVA_HOME .

Step 1: Set environment variables for current session

For tests you can create session variables. The session environment variable is created by writing in terminal:

export RSTUDIO_PANDOC=/usr/lib/rstudio/bin/pandoc 

Variable RSTUDIO_PANDOC is used for RMarkdown.

To use RMarkdown generation outside Rstudio you need to have it set. For example PyCharm you can open the console and run the command above.

If the RMarkdown works properly you can move to the next step and set it permanently.

Step 2: Set environment variables permanently

To set permanent environment variables in Linux Mint follow next steps:

Set ~/.profile variables

  • Add the variable to the bottom of the file:
    • export RSTUDIO_PANDOC=/usr/lib/rstudio/bin/pandoc
    • CTRL + x and then y

    Set ~/.bashsrc variables

    ~/.bashsrc vs ~/.profile

    It depends on your case which one you should use. You can find more information on the link below:

    .profile is for things that are not specifically related to Bash

    .bashrc is for the configuring the interactive Bash usage

    Note you can find more Linux Mint commands and their Windows equivalents here:

    Step 3: List all environment variables in terminal

    To list all environment variables in Linux Mint you can use the next command:

    NVM_DIR=/home/user/.nvm RSTUDIO_PANDOC=/usr/lib/rstudio/bin/pandoc LANG=en_US.UTF-8 GDM_LANG=en_US DISPLAY=:0 

    By using SoftHints — Python, Linux, Pandas , you agree to our Cookie Policy.

    Источник

Оцените статью
Adblock
detector