3

I'm trying to set up Latex, and as part of it need to add to the $PATH. Something I read (probably on here) said modifying /etc/environment was better than adding to .profile (I think because it changes things for all users?).

I've done this, and then when I run . /etc/environment, for the rest of that terminal session everything works fine. When I open a new terminal though, the commands such as latex don't work again. Restarting the computer also doesn't make the changes to /etc/environment be effective across shell sessions.

What can I do to make these changes happen system wide?

UPDATE: I ended up installing through the PPA mentioned in the comments, which installed Tex Live 2016 (and set the environment variables) with no issues.

2 Answers 2

5

You seem to be asking two different questions. The first is related to change variables system-wide and the other related to make LaTeX work so here is the answer to the two:

Change environment variables System-wide

As described here you can add a file under /etc/profile.d/ which has the PATH variable in it:

export PATH=$PATH:<your particular latex path>

Call it /etc/profile.d/latex-path.sh and will be sourced by any shell you log in.

If you want to change the PATH variable only for your user, the preferred method is to edit the ~/.profile with the same line

Make LaTeX work with no hassle

LaTeX package can be installed from the universe repositories as described here and no need to change the PATH variable. Make sure you have enabled the universe repository and input:

sudo apt update
sudo apt install texlive

Or if you like the full distribution (this will install a lot more packages so grab a cup of coffee):

sudo apt install texlive-full
3
  • 1
    I was avoiding installing through apt as it's on the 2015 version still, and I wanted to install the 2016 version. I've found this ppa that seems to provide the 2016 version, so I'll try installing from there. Dec 21, 2016 at 20:33
  • 1
    I always try to find the apt way first. Manual installations are fragile and tend to break things. Glad you found it Dec 21, 2016 at 23:16
  • @Mark Yeah you can try using that PPA. I wrote something to that effect at tex.stackexchange.com/a/324930/5106.
    – edwinksl
    Dec 22, 2016 at 6:18
4

/etc/environment is created and maintained by pam_env PAM module, not by your shell (so you should not source it). This file is read by typical login programs. So you need to logout/login in the usual manner to see the changes (assuming you are not modifying the PATH from somewhere afterwards).

On my system, it is read by:

% grep -l '^[^#].*pam_env' /etc/pam.d/* 
/etc/pam.d/atd
/etc/pam.d/cron
/etc/pam.d/lightdm
/etc/pam.d/lightdm-autologin
/etc/pam.d/lightdm-greeter
/etc/pam.d/login
/etc/pam.d/polkit-1
/etc/pam.d/sshd
/etc/pam.d/su
/etc/pam.d/sudo

If it is not being set to the exact declared value even after restarting you computer:

  • You might have made some syntactic mistake, note the declaration syntax would be KEY=VALUE (per line) so for example PATH=/foo/bar:/spam/egg

  • You are overwriting the PATH afterwards e.g. from a shell session initialization file

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .