[Tex/LaTex] How to run tlmgr in Ubuntu

texlive-2018tlmgrUbuntu

I installed TexLive from https://www.tug.org/texlive/quickinstall.html in Ubuntu 18.04.

I have tlmgr

which tlmgr
/usr/local/texlive/2018/bin/x86_64-linux//tlmgr

I try

tlmgr install tex-gyre

and get:

You don't have permission to change the installation in any way,
specifically, the directory /usr/local/texlive/2018/tlpkg/ is not writable.
Please run this program as administrator, or contact your local admin.
tlmgr: An error has occurred. See above messages. Exiting.

Trying

sudo tlmgr install tex-gyre

I get

sudo: tlmgr: command not found

Trying sudo su first I get

Command 'tlmgr' not found, but can be installed with:

apt install texlive-base

How to perform this operation?

Best Answer

The $PATH used by sudo is different from the one used by $USER, so if the $PATH does not include, in your case, the path /usr/local/texlive/2018/bin/x86_64-linux/, then sudo will not be able to find tlmgr.


On Ubuntu, I highly recommend that you can install texlive via apt. See the Ubuntu package database for a list of all packages related to texlive. Also, from the same domain as you provided, they have a page specifically written for Debian-based (which Ubuntu is based on) systems. If you choose to install the full distribution of texlive, you will not have to install texlive packages using tlmgr and just let apt (the package manager for Debian-based systems) handle that for you. Otherwise, you will only need to run tlmgr with the sudo command, except now the distribution from apt should provide a symlink (or equivalent) to a path that your root account refers to.

However, as pointed out in the subcomments, texlive on apt is possibly outdated.


If disk space is a serious concern, and/or if you are comfortable with the command line, I highly recommend that you install tlmgr as a user instead of root. Follow the guide from Wikibooks for a minimal installation process. Last time I checked, the guide is still up to date. The important point to install tlmgr so that it does not require root access is the following:

  1. You may want to change the directory options. For example you may want to hide your personal macro folder which is located at TEXMFHOME. It is ~/texmf by default. Replace it by ~/.texmf to hide it.

You will need to change the default /usr/local/ to your home directory.

If disk space is not of your concern, then just choose the full distribution schema.


Edits: See also @daleif's comment under this reply, especially these two sentences:

Ubuntu texlive is quite out of date and split into a myriad of Ubuntu packages. So a lot of users do not recommended using the apt version

Just more information for you to watch out for when deciding which installation path you wish to go down.