Fixing ‘sudo does not find tlmgr’ on Ubuntu – Step-by-Step Solution

linuxtexliveUbuntu

I have just installed texlive 2014 on a machine running Ubuntu 14.04 LTS at work. When I enter tlmgr update --self to the terminal for example, it returns the following:

tlmgr: package repository http://mirror.switch.ch/ftp/mirror/tex/systems/texlive/tlnet
You don't have permission to change the installation in any way,
specifically, the directory /usr/local/texlive/2014/tlpkg/ is not writable.
Please run this program as administrator, or contact your local admin.

as expected.

When I use sudo, however, the answer is as follows:

sudo: tlmgr: command not found

Interestingly enough though, when I enter sudo su, the command is well known.
Moreover, when I enter sudo -i and then echo $PATH, the output is:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/texlive/2014/bin/x86_64-linux

As well as the output for echo $PATH when entered without sudo -i:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/texlive/2014/bin/x86_64-linux

Does anybody have a solution to this?

Best Answer

This is a more general UNIX sysadmin question, but you can use visudo to add

Defaults secure_path="/usr/local/texlive/2014/bin/x86_64-linux:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

Edit that path for your environment! See https://wiki.debian.org/sudo or https://www.google.com/search?&q=sudo+secure_path on the web, and the manual page for sudoers(5).