22

I have installed TeX Live 2011 vanilla and I have trouble setting the TeX Live path for root (in Ubuntu 11.10).

The problem is that when I run sudo tlmgr I get:

sudo: tlmgr: command not found

To fix the path for non-root it was sufficient to add

PATH=/usr/local/texlive/2011/bin/x86_64-linux:$PATH

to /etc/profile.

I have tried adding this same line to /root/.bashrc and I have also tried to add it to /etc/profile.d/zzz-texlive.sh like Herbert suggest in https://tex.stackexchange.com/questions/26624/tlmgr-inaccessible/26626#26626 but it does not help.

1
  • Indeed this question is unrelated to TeX, but answered on SO.
    – DevSolar
    Oct 14, 2011 at 7:14

8 Answers 8

22

Quick fix: since you already have the correct $PATH set in your environment (via the /etc/profile modifications) you can use:

sudo env PATH="$PATH" tlmgr

Basically, sudo resets the value of $PATH (the whole environment, indeed) to a "known good" one, and is thus ignoring any changes you made to your local environment. The env command above sets the PATH variable in the environment of the tlmgr it executes, so it runs with the value of $PATH you specify on the command line.

To avoid typing all that for each TeXlive command, you can define an alias in your shell: add the following line to the .bashrc file in your home:

alias psudo='sudo env PATH="$PATH"'

and then you can simply issue this at a command prompt:

psudo tlmgr

In addition, sudo does not run a login shell to execute the command, which is why your "profile.d" tricks did not work for root. You can force sudo to execute a command in a shell, which is an alternate way of achieving the same effect:

sudo sh -l -c tlmgr

Again you can define a shell command alias to shorten this:

alias shsudo='sudo sh -l -c'

which can be used as:

shsudo tlmgr
4
  • Do you mind including a full description of how to set $PATH in my environment? Also, so I have to do env for every command in the TeX Live path that I want to enable for sudo? There's quite a lot of binaries in /usr/local/texlive/2011/bin/x86_64-linux that you might want to run as root.
    – N.N.
    Oct 15, 2011 at 10:05
  • @N.N. I've updated the answer with more details; hope it's clearer now. Oct 15, 2011 at 11:00
  • Cheers! Appreciate your explanations.
    – N.N.
    Oct 15, 2011 at 11:05
  • This is a dramatically more complicated way of doing what was shown in this answer: askubuntu.com/questions/66498/setting-tex-live-path-for-root/…
    – gannex
    Aug 27, 2023 at 8:15
9

If you add the symlinks then you won't need to make a script. You can do this two ways:

Using the GUI:

  1. sudo env PATH="$PATH" tlmgr --gui.
  2. Click 'Actions -> Handle symlinks in system dirs'.
  3. Click 'Update symbolic links'.

Using the command line (untested, since I used the GUI):

  1. sudo env PATH="$PATH" tlmgr path add. (find more information at tlmgr documentation)
4

What worked for me: I started tlmgr in gui mode with

sudo env PATH="$PATH" tlmgr --gui

and then in the third menu chose the last item but one (in my German menu, that is menu "Aktionen" (actions?) and item "Verwaltung der symbolischen Links" (administration of symbolic links?). In the ensuing dialogue window I clicked the button "Symbolische Links erneuern" (renew symbolic links?). Now

sudo tlmgr --OPTIONS

works without problems. I'm sure there's also a command line way of doing this ;)

1
  • This also worked for me! For non-German speakers, you have to do Actions>Handle symlinks in system dirs>Update symbolic links. I had previously appended :/usr/local/texlive/2023/bin/x86_64-linux to secure_path as a workaround, so I restored secure_path to default and logged out and back in again, and I can confirm that it still works. After updating symbolic links via tlmgr --gui, sudo tlmgr --version and tlmgr --version both yield the same result and everything works as expected. Dankeschön!
    – gannex
    Aug 27, 2023 at 8:04
1

To pass the user's $PATH to sudo I modified /etc/sudoers file using the visudo command and add the following line:

Defaults        exempt_group=<group that I belong to>

Now I can execute (e.g.)

sudo tlmgr update all

or

sudo texhash

and everything works perfect.

I would greatly appreciate any comments on this approach.

1

You really don't have to add the directory of tlmgr to the path. A simple quick solution is using which, e.g.:

sudo $(which tlmgr) update --list
1

It is not good practice to install and manage TeX Live using "root" privileges. Instead, create the /usr/local/texlive directory, e.g, using sudo, and then change the ownership to the user that will be managing TeX Live. After that, TeX Live can be installed and updated without using "root" privileges.

2
  • The installation instructions for TexLive do indeed explicitly say that. However everything under /usr/local is normally owned by root. Is it safe to permanently change it? Actually they are indeed owned by root, but readable and executable by everyone, so why doesn't tlmgr just work without sudo (it didn't the last time I tried, but it was several years ago)?
    – Andyc
    Apr 6, 2021 at 9:43
  • Many programs can be installed with simple file copy operations. The tlmgr program uses many other programs to generate formats, ls-R files, font maps, luatex font caches, etc. It also works on many platforms, not just linux. There are examples of system to manage complex systems that have a "systemx" user. The installer and management tools are run as "root", but drop privileges
    – George
    Apr 7, 2021 at 11:00
1

I created my account just to tell how it worked for me. I'm not a linux expert but after reviewing A LOT of forums with same issue and related issues I found this solution, I hope to help. I'm using Ubuntu 20.04 right now. For me it's incredible that there is no simpler installation option in both cases texlive and tlmgr:

Steps:

  • I Downloaded ISO image of texlive (you have to install perl before

  • Mount the image and then open a terminal in the mounted directory:

    `sudo perl install-tl` 
    
  • I choosed full instalation.

  • post instalation PATH export:

export INFOPATH=/usr/local/texlive/2021/texmf-dist/doc/info:$INFOPATH; export INFOPATH

export MANPATH=/usr/local/texlive/2021/texmf-dist/doc/man:$MANPATH; export MANPATH

export PATH=/usr/local/texlive/2021/bin/x86_64-linux:$PATH

  • Then I had the same issue, I mean: when I ran sudo tlmgr: command not found.

Solution:

  • By giving entire PATH to sudo tlmgr in order to Update it:

    sudo /usr/local/texlive/2021/bin/x86_64-linux/tlmgr update --self

  • Then start graphic user interface in order to update all packages and "handle symlinks in system dirs" in Action buton.

    sudo /usr/local/texlive/2021/bin/x86_64-linux/tlmgr --gui

0

As shown in https://askubuntu.com/a/137836/596089, you need to run sudo tlmgr --gui and do Actions>Handle symlinks in system dirs>Update symbolic links. If the superuser can't find tlmgr, you can either temporarily edit the tlmgr dir into secure_path via sudo visudo or, preferably, sudo env PATH="$PATH" tlmgr --gui. This will make sure sudo tlmgr and tlmgr point to the same version of tlmgr.

You must log in to answer this question.

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