331

Debian and Ubuntu have very good texlive packaging. But I'd like to use tlmgr to have a more fine-grained control about upgrades and which packages I want to be installed.

So how do I install "vanilla" TeXLive on Debian/Ubuntu?

Also how do I make dpkg aware that I have TeXLive installed?

Jonas Stein
  • 8,909
Dima
  • 12,427
  • 8
  • 40
  • 53
  • 6
    This might be a better fit for Super User or the Ubuntu SE site, since it's really about the Debian/Ubuntu packaging system, not anything specific to LaTeX. – David Z Aug 05 '10 at 01:01
  • 1
    There's a bug for that: https://bugs.launchpad.net/ubuntu/+source/texlive-base/+bug/712521 . Looks like it might be time to start thinking about an upgrade to a 12.10 pre-release :) – naught101 May 28 '12 at 13:04
  • 4
    Ah, there's a PPA for 12.04 too: https://launchpad.net/~texlive-backports/+archive/ppa. Haven't tried it yet. – naught101 May 28 '12 at 13:08
  • 1
    Could you please announce what vanilla is good for? Just because many people like me are using other distributions. I would like to look for a similar package. – strpeter Feb 11 '13 at 23:27
  • 1
    The repos can be tweaked, as detailed here: How do I install the latest TeX Live 2012? – cmhughes Apr 29 '13 at 21:14
  • 2
    I successfully installed TeXLive 2013 on Ubuntu 12.04 following silex's answer (thanks for that!). Only problem I encountered was a bunch of not really working CTAN mirrors. You may need to change your default mirror by sudo perl install-tl -repository ftp://ftp.fu-berlin.de/tex/CTAN for example. –  Jul 28 '13 at 05:26
  • 1
    Have you seen the difference in your calling and silex's? Silex's has: sudo apt-get install perl-tk --no-install-recommends which I just checked and it works whereas you have for gone the apt-get and perl-tk. So I think the source of your problem was not using the exact line. Here is the output: dustin@dustin:~$ sudo apt-get install perl-tk --no-install-recommends Reading package lists... Done Building dependency tree Reading state information... Done perl-tk is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. – dustin Jul 29 '13 at 15:01

11 Answers11

432

These instructions have been updated for Ubuntu 16.04 and TeX Live 2021, they will probably work on most Ubuntu/Debian distributions.

Installation

Installing "vanilla" TeX Live is not as hard as you think. Things you will need:

  • An internet connection.
  • About 4 GiB of free space (2 GiB if not installing documentation).
  • Root (sudo) powers.

Note: the instructions are meant for the terminal and for installing the "original" most up-to-date version of texlive. If you're uncomfortable with the command line and plenty of sudo instructions, you can probably still install the texlive-full package from the Software center; you will end up with the "stock" version of texlive, which usually lags a bit behind the latest distribution of texlive.

Installation of dependencies

The following packages are required for this guide: wget, perl-tk. Install them with:

sudo apt install wget perl-tk

TeX Live Installer

First the official installer needs to be downloaded with the following commands:

wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
tar -xf install-tl-unx.tar.gz
cd install-tl-20220211

The install-tl-20220211 folder is likely to be named differently. You can probably type install-tl and then press tab to autocomplete the folder name.

Now the installation can begin, run:

sudo ./install-tl

This starts the installation process. You can change all kind of options here, most of the the default options are correct. In order to have working executables and man/info -pages after installation where (1) is recommended option in Unix/Linux, while (2) in Windows:

  1. Create the following environment variables for finding your new installation in TeXLive 2021:
    export PATH=/usr/local/texlive/2021/bin/x86_64-linux:$PATH    
    export INFOPATH=$INFOPATH:/usr/local/texlive/2021/texmf-dist/doc/info
    export MANPATH=$MANPATH:/usr/local/texlive/2021/texmf-dist/doc/man
    

This can be added to ~/.profile to automatically apply when opening a terminal.

  1. You can have the installer create symbolic links for you by changing the options: Use o to change the options and l to create symbolic links. The default locations are correct, so just press enter to use them. Use r to return to the installation menu.
    If for some reason you overlooked this and ran the installer, it is possible to create the symlinks retrospectively using the command: tlmgr path add. See the relevant documentation for more details.

In some cases changing the other options can, of course, be helpful. Not installing the doc and source trees will save you a lot (1.8 GiB, 50%) of disk space. This comes with the downside of having to look up documentation online, instead of locally.

If you want to reduce disk space further you can also change the installation scheme or collections, but this will result in not having certain packages installed by default. You can, however, install them later through the TeX live manager.

Press i to start installation. The full installation is likely to take a long time, say between one and three hours (even on relatively fast connections). As usual, your mileage may vary, but if fewer components are selected in your settings, the process is hastened, and the missing components can be easily installed later.

Interruptions: If, for some reason, the installation is interrupted it can probably be resumed by running the installer again. This will prompt you to continue the installation. If you want to start the installation from the beginning it's probably wise to remove the following installed elements +/- possible elements mentioned in the thread answer How to remove everything related to TeX Live for fresh install on Ubuntu?

sudo rm -rf /usr/local/texlive/2021

Failures: Such a long installation process may fail due to interruptions in communications or other reasons. In such a case, you may want to to restart the installation, but this time choose the smallest configuration that would get it going. Then, you can install all missing components with sudo tlmgr --gui.

Finalising the installation

If everything went well all TeX-related commands should work. Verify this by checking the output of which tex, which should be /usr/local/bin/tex.

Fake packages

Now TeX Live works, but it's also necessary to make Ubuntu think you've installed TeX Live. This can be done with the equivs package:

sudo apt install equivs --no-install-recommends freeglut3
mkdir -p /tmp/tl-equivs && cd /tmp/tl-equivs
equivs-control texlive-local

Note: If your /tmp is mounted wit noexec flag, the build will fail as described here. You may just use another directory instead of /tmp in this case.

Then, you'll have to edit texlive-local. For this use the file provided here corresponding to the version you are installing. For instance, for 2020 use:

wget -O texlive-local https://tug.org/texlive/files/debian-equivs-2021-ex.txt

More information about required edits can be found in the TeX Live Debian guide.

Now you can build the package and install it (exact name of .deb is created in first command below; you can also use tab autocompletion):

equivs-build texlive-local
sudo dpkg -i texlive-local_2021-1_all.deb
sudo apt install -f

After this installing texworks through the package maintainer won't install TeX Live again. You can check if this is indeed the case by installing TeX-related packages like texworks, texstudio, qtikz or kile.

Fonts

If you want to install all OpenType and TrueType fonts so you can use them in other programs as well, you'll have to add the TeX Live fonts to the system configuration:

sudo cp $(kpsewhich -var-value TEXMFSYSVAR)/fonts/conf/texlive-fontconfig.conf /etc/fonts/conf.d/09-texlive.conf
gedit admin:///etc/fonts/conf.d/09-texlive.conf

Remove the line containing type1 and save. Now run:

sudo fc-cache -fsv

Updating

If you have installed from a CD, DVD, or an ISO image, you should update your installation to the most recent version of all packages. To do so, run the following two commands:

sudo tlmgr update --self
sudo tlmgr update --all

From now on, you can update TeX Live through the TeX Live Manager with the GUI interface:

sudo tlmgr --gui

It might complain about missing 'Tk', this can be solved by installing perl-tk:

sudo apt install perl-tk --no-install-recommends

Launcher

You can also create a launcher for your desktop environment:

mkdir -p ~/.local/share/applications
cat > ~/.local/share/applications/tlmgr.desktop << EOF
[Desktop Entry]
Version=1.0
Name=TeX Live Manager
Comment=Manage TeX Live packages
GenericName=Package Manager
Exec=pkexec /usr/local/texlive/2021/bin/x86_64-linux/tlmgr --gui
Terminal=false
Type=Application
Icon=system-software-update
EOF

You may need to logout and login again for the changes to take effect.

Note: If the $XDG_DATA_HOME variable is set, use the value of that instead of ~/.local/share/applications. It is also possible to use /usr/share/applications for a system-wide launcher.

Upgrading to the next TeX Live

To upgrade you need to download and run the installer again. Do not forget to have the installer create symbolic links.

It might also be a good idea to run the font section again. You can remove the old distribution(s) by running (for example):

sudo rm -rf /usr/local/texlive/2019
sudo rm -rf /usr/local/texlive/2020

Uninstalling TeX Live

To remove TeX Live completely you need to undo everything you've done:

References and sources

Silke
  • 10,511
  • I've installed this succesfully, but I can't for the life of me figure out where the editor texworks is? Its not showing up in my Applications menu – masfenix Feb 02 '13 at 03:14
  • 1
    @masfenix: TeXworks is not installed by TeX Live, you need to install it through the software center. – Silke Feb 02 '13 at 10:31
  • 4
    @Silex Thanks for the nice howto. Works perfect... – Stefan Waldmann Feb 19 '13 at 12:27
  • Thank you for these instructions. They were a life-saver. I wouldn't regard the installation as hard but wouldn't regard it as easy, either... – Glutanimate Mar 16 '13 at 12:28
  • How can I install extra packages such as texlive-publishers, on /usr/local/texlive/2013/? – Rasoul Jul 04 '13 at 15:41
  • @Rasoul: most CTAN packages included in texlive-publishers (list) are installed with texlive. Missing CTAN packages can be installed trough the TeX Live Manager. – Silke Jul 04 '13 at 18:30
  • 2
    @Silex: When I try to install texlive-publishers with the command tlmgr install texlive-publishers I receive the error You don't have permission to change the installation in any way, and if I do sudo tlmgr install texlive-publishers I receive the error sudo: tlmgr: command not found. I use Ubuntu 12.04 if it does matter. – Rasoul Jul 04 '13 at 18:50
  • @Rasoul: there is a difference between Ubuntu packages (from the Ubuntu repository) and CTAN packages (from CTAN). The latter is what you want. The Ubuntu texlive-publishers package can't be installed because you are running vanilla TeX Live. But as texlive-publishers is actually a collection of CTAN packages you can install those (if they haven't been installed already). If you have issues, please ask me in the chat to avoid extended discussion in the comments. – Silke Jul 06 '13 at 10:20
  • The example-link for building the package texlive-local ist outdated: http://www.tug.org/texlive/files/debian-equivs-2013-ex.txt should work instead. – Martin - マーチン Nov 28 '13 at 11:47
  • Wouldn't it be easier to select (in the installer) options->create symlinks in standard directories to create symlinks to the default directories /usr/local/bin, /usr/local/man, /usr/local/info? That way you won't have to do any manual linking. – someonr Nov 29 '13 at 01:31
  • @Silex: I have faked the tex installation for Ubuntu as described in your answer. But when I tried to install a dviware package like "catdvi", still the synaptic-package-manager tries to download and install tex-common, texlive-binaries and texlive-common. Although these packages are included in the "Provides:" entry of the equivs script (texlive-local). Any idea? – ramgorur Mar 16 '14 at 03:45
  • Hi, just a small thing to point, in the texlive-local file, we need to explicitly set Package: texlive-local, otherwise I get error in the next step. – Swagatika Mar 21 '14 at 10:02
  • 1
    I realise this is how most people proceed but upstream are quite explicit in recommending that TeX Live not be installed with root privileges. (And it works beautifully if you follow their advice and do not do so!) – cfr Apr 15 '14 at 22:09
  • 5
    For those wondering, /etc/environment should be replaced by /etc/login.defs when dealing with Debian, according to tug.org. In this file you can edit your path. – Clément Jul 08 '14 at 21:10
  • 41
    For the record, this is one of the best answers on the entire SE network. – mmdanziger Oct 19 '14 at 12:21
  • I can't create the /opt/texbin symbolic link. It says there is no such file or directory. I have checked and I indeed have the /usr/local/texlive/2014/bin directory, but I don't even have a /opt folder – Mario S. E. Dec 19 '14 at 15:28
  • 1
    @MarioS.E.: In that case you can create it: sudo mkdir /opt. – Silke Dec 19 '14 at 17:09
  • This works perfectly for me, except the step when I am supposed to change /etc/environment. Editing the /etc/environment file doesn't work. But editing the ~/.bashrc file works. – I Like to Code Apr 12 '15 at 11:43
  • I added more detailed instructions on how to manage /etc/environment. – Yossi Gil Nov 10 '15 at 09:04
  • I would like to change the icon of tl-manager. I went to gksudo nautilus and then at /usr/share/applications and i changed the icon and i logged out However, it didn't has an effect – Yorgos Nov 18 '15 at 00:33
  • I can't make texlua install-getnonfreefonts work. When I installed TeX Live 2015 following the instructions on tug.org it worked (no \opt stuff, PATHs written in .bashrc), but I didn't know how to install TeXworks correctly. Now when I run texlua install-getnonfreefonts as root (after sudo -s) i get: The program 'texlua' is currently not installed. You can install it by typing: apt-get install luatex. Should I do it or would it be duplicated?
    Note: Running sudo texlua install-getnonfreefonts results in sudo: texlua: command not found.
    texlua -v shows the credits.
    – Arch Stanton Nov 23 '15 at 14:04
  • Solved. Use sudo su instead of sudo -s to become root before running texlua install-getnonfreefonts. – Arch Stanton Dec 02 '15 at 21:34
  • On fedora, there is no equivs. I am not sure what is the equivalent of equivs. If the gui complains then one needs to install perl/Tk. What is with different names for same package across distributions? – Kabira K Feb 28 '16 at 16:17
  • @Silke It's time to update this for Ubuntu 16.04! – luchonacho Aug 08 '16 at 15:53
  • Binaries installed in /usr/local/texlive/... should be sym linked from /usr/local/bin, if anywhere, and not from /opt. Different distros use /opt in different ways, but I don't know any which would recommend this. (Unless Ubuntu does something really bonkers. Maybe it does.) – cfr Aug 19 '16 at 22:46
  • 1
    I got the error texlive-local depends on freeglut3; however: Package freeglut3 is not installed. when I was trying to run the command equivs-build texlive-local. Maybe you should add freeglut3 to the list of packages required? – I Like to Code May 16 '17 at 16:02
  • @ILiketoCode: maybe, but theses dependencies might change. I recommend doing an apt install -f after installation of the faked package. – Silke May 16 '17 at 19:54
  • 2
    which tex in my machine answers /usr/local/texlive/2017/bin/x86_64-linux/tex. Did I have to set a path for symlinks in the installation options? – Arch Stanton Aug 02 '17 at 10:44
  • @Silke I have installed texlive-2016 long days ago. A few days ago when I installed updates in my Ubuntu 14.04 texlive-base was also installed. How can I remove texlive-base ubuntu repo packages? my question is here. – alhelal Sep 06 '17 at 16:52
  • @BandaMuhammadAlHelal Make sure your paths are correct (under TeX Live Installer) and follow the instructions from 'Fake Packages'. Uninstall all packages provided by the equivs file. – Silke Sep 06 '17 at 21:02
  • @Silke it might be helpful if you would edit your answer so that who has installed the texlive and now want to tell to dpkg that he install texlive like me can use your answer. – alhelal Sep 14 '17 at 11:56
  • @Silke I follow the instructions from "Fake Packages". but error occurred.https://pastebin.ubuntu.com/25533616/ – alhelal Sep 14 '17 at 12:07
  • @Silke dpkg error is solved. now see this – alhelal Sep 14 '17 at 13:24
  • Using sudo will be unnecessary, and therefore discouraged, for the vast majority of users, who can just install into their home directory. Installing into /usr/local may make sense if several users on the system want to use it (and even then, I wouldn't do it). – fkraiem Sep 26 '17 at 04:29
  • Had a problem with PATH. export commands didn't work. This post involving RStudio solved the problem for me. – jmjr Mar 10 '18 at 15:59
  • 1
    @Silke gksu has been dropped from Debian, Ubuntu 18.04 and Mint 19 (e.g. https://forums.linuxmint.com/viewtopic.php?t=268140). So, probably, some update for the launcher is required. – gusbrs Jul 06 '18 at 20:19
  • pkexec env PATH=$PATH DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY tlmgr gui this can be one of replacements to gksu containing line I think (more ideas at discussion https://itsfoss.com/gksu-replacement-ubuntu/#comments/292236) – Leonid Jan 06 '19 at 17:48
  • Is it bad to not remove the texlive from apt before doing this? – PlasmaBinturong Mar 29 '19 at 10:06
  • 1
    I did something similar to this, but installed as a different user, instead of root. If you use tex, for example, you would chown tex:tex /usr/local/texlive/, then use sudo -u tex -g tex instead of sudo on all commands, including the installers. So, you might want to alias sudo -u tex -g tex ${which tlmgr} update --self --all. This is useful because exploits in installers don’t have root and can only mess with your TeX installation. – Davislor Jun 24 '20 at 23:14
  • @PlasmaBinturong Theoretically, it’s fine, so long as your paths are set up correctly so that all users are running the correct binaries. – Davislor Jun 24 '20 at 23:17
  • Can't make the desktop launcher to work. gedit does not seem to support options d, s and D. – luchonacho Dec 28 '20 at 14:29
  • 3
    I followed it for installing Texlive 2021 in ubuntu 20.04 LTS. But sudo tlmgr update --self is not working. While giving the full path, like: sudo /usr/local/texlive/2021/bin/x86_64-linux/tlmgr update --self, then it's working. – raf Jul 11 '21 at 15:18
  • Great guide, but unfortunately, it does not seem to work on WSL. equivs-build says: "fakeroot, while creating message channels: Function not implemented" Seems as if I need to stay at my old version from 2017 ... – Christoph Thiede Sep 16 '21 at 17:26
  • @raf : use sudo env PATH="$PATH" tlmgr --gui then in Actions, you can update the symbolic links. Solution found in this message : https://askubuntu.com/a/137836/376526 – Tobard Dec 26 '21 at 10:25
  • When attempting to do a shared global install, ensure that the umask is set to 0022 such that the resulting stuff is readable / executable by others. – Stefan Sep 30 '22 at 10:36
  • @Tobard I am able to run e.g., sudo env PATH="$PATH" tlmgr --version but tlmgr --gui gives me a segmentation fault error. I thought it was permissions-related, so I ended up just adding /usr/local/texlive/2023/bin/x86_64-linux to secure_path, but that didn't help. Do you have any idea what could be causing the segmentation fault issue? – gannex Aug 27 '23 at 06:18
  • I installed texlive this way and everything worked, but I can't run tlmgr gui. Running sudo tlmgr --gui results in [1] 687053 segmentation fault sudo tlmgr --gui. Anyone have any ideas? – gannex Aug 27 '23 at 07:24
86

Use the net installer script from this page on the official tug.org website to install “vanilla” TeXlive.

Tricking Ubuntu into satisfying the package dependencies is more involved and requires using the equivs package. There are basic guidelines for doing so in this post on TeXblog (an unofficial blog). (This page is a bit old and was aimed at older versions of Ubuntu.) The package list there is a bit old, but the same overall procedure should still work. I’m afraid I don’t have a list offhand of what the dummy package should contain; maybe someone else will. (You can always just create new dummy packages as need be if you try to install something it tells you you have unsatisfied texlive dependencies.)

frabjous
  • 41,473
  • 15
    See also: http://www.tug.org/texlive/debian.html , section "Vanilla TeX Live on Debian" which is also valid for Ubuntu (since Ubuntu is a Debian based distribution) –  Feb 08 '11 at 18:01
  • 4
    I asked a related question here: http://tex.stackexchange.com/questions/52388/installing-texlive-on-debian-x86-64-platform. If anyone is having trouble installing vanilla texlive, perhaps some information in that post will help. – void-pointer May 18 '12 at 13:28
38

I wrote a script that automates Silex's answer and does (optionally) a lot more. It supports Ubuntu versions 12.04 up to the current version.

Download install-tl-ubuntu and run it as

sudo ./install-tl-ubuntu

To download that script, run

wget https://github.com/scottkosty/install-tl-ubuntu/raw/master/install-tl-ubuntu && chmod +x ./install-tl-ubuntu

Below I give the list of features from the GitHub repository

  • installs TeX Live 2013
    • automatically finds the fastest repository
    • gives updated progress of the install
    • restarts automatically if install fails
  • tlmgr can then be used to keep your install up-to-date
  • notifies apt so that apt does not try to install the Ubuntu texlive-* packages as dependencies (e.g. if you do sudo apt-get install lyx)
  • links to the folder where Ubuntu installs TeX files so that when you install Ubuntu packages (e.g. FoilTeX and noweb) with LaTeX files, they will be available
  • adds TeX Live fonts to be used system-wide
  • other font-related conveniences
    • tells AppArmor to allow Evince to access the TeX Live fonts
    • can install TrueType fonts that user provides (--truetype-dir)
    • can install IvriTeX Hebrew fonts (--hebrew)
  • optionally installs additional LaTeX files for common journals that are not included in TeX Live 2013 (--more-tex)
  • works non-interactively and thus can be added to a batch install script
  • tlmgr can be run from the desktop menu (if 'gksu' package is installed)
  • install can be done from an ISO file (--iso)

For more details, see

./install-tl-ubuntu --help
scottkosty
  • 13,164
  • 1
    Many many thanks for that. I updated Ubuntu to 14.04 and that broke the LaTeX completely on my machine. 'Usual' instillation didn't work but your script worked like a charm. One question though. I downloaded install-tl-ubuntu to my home directory. After installation was complete it left behind some folders: install-tl-20140417, debian-control-texlive-in.txt, install-tl-1.log, install-tl-ubuntu_EXTRAS.log, install-tl-unx.tar.gz, mirrorCandidates.logand mirrorWgets.log. Can they all/some be deleted? – radek May 16 '14 at 19:06
  • @radek Glad it was useful. You do not need those files anymore. – scottkosty May 16 '14 at 19:47
  • @scottkosty Looks very nice! (I don't use Ubuntu/Debian, though.) Can you run it as a non-root user, as upstream recommends? Even better, could you have it create a non-root user to manage the installation and then proceed as that user? (So the user would also then be used for subsequent updates etc.) – cfr Nov 19 '14 at 03:05
  • @cfr (I'm sincerely sorry for the very late reply, not sure how I missed this). No, unfortunately it cannot be run as non-root. I think this would be nice (and even recommended, as you say). Patches are welcome :) – scottkosty Dec 04 '15 at 22:45
  • @scottkosty Not exactly a patch, but I have written instructions in supplemental answer here. This includes coverage for Debian/Ubuntu, although I can't test that myself. (But somebody else helped with this bit, as you'll see from the comments.) – cfr Dec 05 '15 at 02:10
  • I don't know exactly what you've done, but that is probably not the best way to allow Ubuntu-installed TeX stuff to be used. The best is to add it as an additional tree. (I asked a question about how this should best be handled a while back, and this was the answer I got from, I think, Norbert, if I remember correctly. I regard that as definitive for TeX Live in the absence of protestations to the contrary from one of the other developers.) – cfr Dec 05 '15 at 02:22
  • Also, if you do not test to ensure that you are on a system you wrote the script for, I think you should. Yes, people should read what it says on the tin. But, no, people won't necessarily even realise it is a tin. ;) – cfr Dec 05 '15 at 02:29
  • The readme in github says that the current version "TeX Live 2016". Is there also support for Ubuntu 16.04? – Erel Segal-Halevi Aug 03 '16 at 13:45
  • 1
    @ErelSegal-Halevi I have heard from many Ubuntu 16.04 users that install-tl-ubuntu works well. I have also used it on a few Ubuntu 16.04 installations and it works smoothly for me. There might be a warning that 16.04 isn't yet "officially" supported but that's just because I haven't gotten around to confirming and tweaking the TeX Live -> Ubuntu package mappings for 16.04. But again, I have not heard about a single problem specific to Ubuntu 16.04. If you happen to use the --hebrew option of install-tl-ubuntu, I'd be interested in hearing from you regarding whether it works well. – scottkosty Aug 04 '16 at 01:09
  • I did install-tl-ubuntu --hebrew --more-tex on Ubuntu 16.04. So far it works well. I managed to compile this Hebrew document: https://www.cs.bgu.ac.il/~yoavg/tech-notes/heblatex/hebexample.tex well. Thank you very much for this useful script! – Erel Segal-Halevi Aug 04 '16 at 05:06
  • @ErelSegal-Halevi great! Thanks for confirming. Note (just in case you are curious) that we also have a couple of LyX Hebrew manuals. See /usr/share/lyx/doc/he/Intro.lyx and /usr/share/lyx/doc/he/Tutorial.lyx – scottkosty Aug 04 '16 at 05:37
  • 1
    @scottkosty I am also now trying your script for use in Hebrew on 16.04 (I only added the --hebrew option). Basically the Hebrew works, but your script does not install the culmus-latex package (https://www.guyrutenberg.com/culmus-latex/) which, as far as I understand it, is needed in order to use the entire variety of the culmus fonts, as well as the Nikud. This is, of course, unless you use XeTeX. I also did not manage to install it using tlmgr as it is not in the repository, nor by the instructions provided by the package. Anyway, thanks for the script! – Ur Ya'ar Sep 08 '16 at 18:43
  • @UrBen-Ari-Tishler thanks for this feedback. It is good to know that the Hebrew works (in fact, I just tested with a 40 page non-trivial Hebrew document and pdfTeX compiles it well). I know nothing of Hebrew or fonts, but if you are interested in helping me incorporate a wider variety of Hebrew fonts, please open an issue on the install-tl-ubuntu github page and we can work together to improve things. I'd appreciate your feedback. – scottkosty Sep 09 '16 at 02:26
  • @scottkosty I opened an issue. But I'm not a programmer, and rather new to Linux, so I don't think I can help with the technical side of things... – Ur Ya'ar Sep 09 '16 at 09:11
  • @UrBen-Ari-Tishler well together we make one Hebrew-speaking programmer so we will figure it out :). I promise I will take a look at the Github issue but not sure exactly when that will happen. For archival purposes (e.g. in case other Hebrew users happen along these comments and want to follow the progress or give input), the github issue is here: https://github.com/scottkosty/install-tl-ubuntu/issues/27 – scottkosty Sep 09 '16 at 14:25
  • I tried running the script, but it would restart repeatedly (11 times) and then abort. When I checked the log file, I'm getting a 404 not found on "http://mirror.utexas.edu/ctan//install-tl-unx.tar.gz". Is there anything I can do to fix this? – Zach Oct 24 '16 at 00:37
  • @Zach can you open an issue on the github repo? One solution might be for you to manually select a repository using the --repository option. See the output of install-tl-ubuntu --help. – scottkosty Oct 24 '16 at 04:45
18

Some comments:

  1. According to the Ubuntu package listing, the texlive package is a dummy package whose only purpose is to install a decent selection of dependencies. So it is possible to install this texlive package without installing any of its dependencies. This requires using dpkg instead of aptitude (as far as I can see, and I don't know if it's possible through the synaptic package manager): passing the --ignore-depends=texlive option to dpkg will cause it to forego the dependency check. Then anything that depends on texlive will afterwards install fine (I believe), though if something depends on, say, texlive-bin then it will complain.

  2. Whilst checking the options for aptitude and dpkg for the above, I came across the following snippet from aptitude: the command

    aptitude install texlive&m
    

    will mark texlive as having been manually installed. (Note that the & will probably need some sort of shell escaping to avoid it being interpreted by the shell.) I believe this basically says to the system "I've installed this myself, so you can stop bothering with it.".

  3. Possibly the easiest solution (and the one I use myself) is to simply ignore the system one and install your own version as well. If you do this right, you get the best of both worlds because one possible problem with replacing the system version with your own version is that the upgade may break some dependencies from other packages. It's less likely with something like TeX, but you can imagine that lots might go wrong if you upgrade one of the core system libraries without upgrading all the programs that use it. This is what the /usr/local directory is for. Put your installation of TeXLive in /usr/local/texlive or somewhere using the standard installation (as mentioned by frabjous, for example). By ensuring that /usr/local appears before /usr/bin in your path, and that $TEXMFCNF points to the right place, you can effectively ignore the system installation whilst being able to fall back on it if necessary.

Andrew Stacey
  • 153,724
  • 43
  • 389
  • 751
  • 1
    Except that by policy none of the packages depend on the "decent selection packages" e.g. texlive since they are subject to change to something like equivs will be required. – Dima Aug 05 '10 at 10:39
  • @Dima: I was afraid of that. In that case, I'd go for option 3 with option 2 if you really don't want to install the system version. – Andrew Stacey Aug 05 '10 at 11:17
  • 4
    Ad 2: packages marked as "manually installed" are still regular packages. The difference is that if all packages that depend on them are removed the "manually installed" packages will be kept. In contrast, if all packages that depend on an "automatically installed" package are removed, the package itself will be removed too. By default, manually installed packages are those that you actually select for installation in aptitude, automatically installed are those pulled in as dependencies. You can override this by marking a package as manually or automatically installed. So 2 would not work. – Jan Hlavacek Aug 29 '10 at 03:32
  • @Jan Hlavecek: Thanks for the clarification. Option 3 seems best, then. – Andrew Stacey Aug 30 '10 at 07:16
  • 2
    concerning option 3, you don't need to set TEXMFCNF and it is recommended not to set it. Setting the PATH is enough. – mpg Mar 17 '11 at 11:05
  • In bash, does one need to type aptitude install texlive&m or aptitude install texlive\&m? – isomorphismes Sep 09 '11 at 20:02
  • @Lao: I don't use bash so I don't know. I'm pretty sure that the first won't work, but I don't know about the second. – Andrew Stacey Sep 09 '11 at 20:55
  • (3) spells trouble and confusion, in my opinion. I really wouldn't recommend it. I'm sure you know what you are doing and can avoid the pitfalls, but for mere mortals it is fraught with danger. – cfr Dec 21 '16 at 01:06
18

PLEASE THINK BEFORE EDITING! Please do NOT edit this answer in ways which render it distro-specific. Although this question specifically addresses Debian/Ubuntu systems, it serves to provide information to users of GNU/Linux more generally. The way things work on your system may not be the way they work on all GNU/Linux systems - not even all Debian-based systems.

Note that upstream recommend not installing as root. Installing as root introduces a level of risk and has no benefits whatsoever.

Note that I trust the people who are in charge of TeX Live. However, I have been given reason to believe that they are fallible and fallible beings screw up however competent and however well-intentioned they are. Moreover, servers get hacked, downloads get corrupted or intercepted. Shit, basically, happens.

The crucial point is that there is zero benefit to installing with root privileges. All it gets you is an increased security risk. While it may be small, I see no reason to take it.

It is possible to install and manage the installation as your ordinary user. However, that only protects your system directories. Your home directory - where you probably keep all of your personal files and projects - remains exposed. Fortunately, it is easy to protect /home as well.

If you want to follow upstream's advice, then, here is how I do it...

Set up a dedicated user/group and create a suitable home for it

This is the only part you need root privileges for.

The following are generic instructions which should work for most GNU/Linux distros. If you are using a Debian based system or another distro which features the adduser script, see the note below for an easier method. Otherwise, use the useradd command as follows.

Generic GNU/Linux distro: useradd

sudo useradd -d /usr/local/texlive -m -r -U -s /bin/sh texlive

This creates a new user, texlive, as a member of a new group, texlive. It creates a home directory for texlive at /usr/local/texlive.

If you have previously installed TeX Live from upstream, omit the -m flag from the above command. Instead, once you have created the new user, do this:

sudo chown -Rh texlive:texlive /usr/local/texlive

Be sure to set a password:

sudo passwd texlive

You will be asked to choose and confirm a password. Note that what you type will not show up on the screen at all. Just type the password and hit enter. Then do the same to confirm.

If you wish, you can choose some other name for the user/group, so long as it is unique on your system. Suppose you want to use tladmin:tladmin, then you need

sudo useradd -d /usr/local/texlive -m -r -U -s /bin/sh tladmin
sudo passwd tladmin

or, if you've previously installed TeX Live as another user, omit the -m flag and add

sudo chown -Rh tladmin:tladmin /usr/local/texlive

In what follows, <username for texlive> denotes the user name and group of texlive> denotes the group. So, in our examples, both are texlive or tladmin.

Debian-based distro: adduser

If you are using Debian or a Debian derivative then, according to this question and given Andrew Cashner's experience, you should probably use adduser rather than useradd. According to Andrew:

sudo adduser texlive

or, if you want to use a different user name, such as tladmin

sudo adduser tladmin

is sufficient but notice that this will create an additional directory /home/texlive or /home/tladmin which the useradd method does not. In this case, <username for texlive>'s home will be /home/<username for texlive> and not /usr/local/texlive. Moreover, <username for texlive>'s primary group will depend on the defaults for your system: you might get <username for texlive>:<username for texlive> (e.g. texlive:texlive or tladmin:tladmin) or you might get <username for texlive>:staff (e.g. texlive:staff or tladmin:staff) or <username for texlive>:users (e.g. texlive:users or tladmin:users). You can use

groups <username for texlive>

to discover which group <username for texlive> is assigned to. For example, use

groups texlive

if texlive is the name of the user you added, or

groups tladmin

for tladmin.

If the result includes <username for texlive> (e.g. texlive or tladmin), use this group in what follows. Otherwise, you probably only get a single group listed e.g. users and should use that one. In the following, I'll call this group <group of texlive> and denote the user name you're using by <username for texlive>. If you have not installed from upstream before:

sudo mkdir -p /usr/local/texlive
sudo chown -Rh <username for texlive>:<group of texlive> /usr/local/texlive

If you have installed from upstream before, then just:

sudo chown -Rh <username for texlive>:<group of texlive> /usr/local/texlive

Switch to the new user before installing

Now login as <username for texlive>:

su -l <username for texlive>

Give the password and you will be in <username for texlive>'s home directory. That is, you will be in /usr/local/texlive. (If you used the Debian method above, cd /usr/local/texlive to move from the home directory.)

Now follow Silex's instructions but omit all occurrences of sudo. You don't need them.

Note that this method not only protects your system directories, it also protects your home. The <username for texlive> user cannot write to your normal home directory. So even if somebody screws up and the installer tries to delete all your documents, it will not be allowed to do so. In fact, if you were to get any permissions errors whatsoever, that would be a red flag. The installer is not supposed to touch anything outside /usr/local/texlive at all.

Aftercare: when to use root

You will need sudo to install the fake packages and to integrate TeX Live's fonts into the system configuration. That's because these steps involve system directories. The fake packages get installed for the system and the font configuration involves altering files in /etc. That all necessarily requires root privileges.

Maintenance: updating your installation

When you are ready to update TeX Live, simply login as <username for texlive> prior to running the update:

su -l <username for texlive>
# give the password
tlmgr update --all

Do not use sudo or switch to root. The whole point is that tlmgr runs as an unprivileged user and cannot touch your home or system directories.

In general, if you want to change anything under /usr/local/texlive, su <username for texlive> before you do it. If you want to do something in /etc or under /opt, you need root privileges (sudo or similar).


Loosely related notes

The use of single configuration files in /etc seems to be going out of fashion. If you find that /etc/environment does not set your PATH, it may be somewhere else. For example, on some systems, PATH is set in /etc/profile and should be extended by adding a file named something like /etc/profile.d/texmf.sh for shells such as sh or bash:

# /etc/profile.d/texlive.sh 
if [ $UID != 0 ]
then
        [ -d "<path to binaries>" ] && export PATH="<path to binaries>:${PATH}"
fi

This avoids adding TeX Live binaries automatically to root's PATH. In order to avoid needing to adapt this file when you install a new edition of TeX Live, you can use a system of symbolic links.

cd /usr/local/texlive
ln -s <YYYY>/bin/x86_64-linux bin.<YYYY>
ln -s <YYYY> current.<YYYY>
ln -s bin.<YYYY> bin
ln -s current.<YYYY> current

Then/etc/profile.d/texmf.sh can contain just

# /etc/profile.d/texlive.sh 
if [ $UID != 0 ]
then
        [ -d "/usr/local/texlive/bin" ] && export PATH="/usr/local/texlive/bin:${PATH}"
fi

and PATH will be set to include the current binaries automatically. When you install a new edition of TeX Live, you just add further links (2 per edition) and adjust the current and bin link to point to whichever edition you want to be active. This can all be done as <username for texlive>, with no need for root privileges. (That is, the .sh file in /etc/profile.d must be created with root privileges, but you need not touch this file when installing or activating a new edition of TeX Live.)

cfr
  • 198,882
  • 1
    This is an excellent suggestion. I’ve often been tempted to install TeX Live as root because some editors (Emacs, for one) open .sty files upon compilation errors, and then I’m in danger of modifying the files without noticing what I’m doing (absent-minded). This approach prevents that as well as protecting /home. – Thérèse Jun 18 '15 at 02:03
  • @Thérèse Thanks. That's a good point. My editor tends to do that too. I've never installed TL as myself I went from root to a special user. But it is definitely another good reason to keep a separate account. It also means if there's anything of your own you don't want to touch, you can stick it in TEXMFLOCAL which is managed by the dedicated user as well. (At least, using the above instructions it ends up that way.) This method is really, really easy to use. It really is just creating a new user with a special home and setting it up that is a little fiddly. But you only do that once.... – cfr Jun 18 '15 at 02:18
  • 2
    I installed TeXLive per your instructions on Debian, but with useradd I ended up with a fairly crippled user account for the texlive user. In particular, I was unable to set the path, which meant I couldn't use tlmgr. I tried again using the newer utility adduser (simply adduser texlive with no additional options required) and everything worked better. The only thing I had to do as root was create a /usr/local/texlive directory and chown texlive:texlive /usr/local/texlive so that the texlive user could install there. – musarithmia Sep 03 '15 at 15:52
  • On adduser vs. useradd, see http://unix.stackexchange.com/questions/182180/why-is-the-home-directory-not-created-when-i-create-a-new-user – musarithmia Sep 03 '15 at 15:54
  • @AndrewCashner The thing is, adduser is distro-specific. Some distros do not provide such a wrapper at all (e.g. mine). I'll see if anything about useradd has changed, though. Thanks for the heads up. Strange that useradd would be crippled on Debian. As I say, adduser is not generally available. – cfr Sep 03 '15 at 19:25
  • @AndrewCashner I've updated in light of your comments. Unfortunately, I cannot test this personally as my system does not have the adduser wrapper. The answer there which claims useradd is 'deprecatedis wrong, at least as a general claim.adduseris just a Debian wrapper arounduseraddas far as I know. In any case,adduser` is not a generic GNU/Linux command and clearly is *not* deprecated on other systems. (I realise this question asked about Debian/Ubuntu specifically, but it is the only question on this so it seems reasonable to include information for other distros.) – cfr Sep 03 '15 at 21:31
  • @cfr Just to clarify: If you use adduser the system will take care of setting up the home folder (which, as you say, is /home/texlive) with suitable .profile and other defaults. Then you still have to create the texlive folder and give its ownership to texlive by doing sudo mkdir /usr/local/texlive && chown texlive:texlive /usr/local/texlive. After that you can login as texlive and do the installation. – musarithmia Sep 03 '15 at 21:54
  • I would suggest setting null shell for user texlive (/bin/false or /bin/nologin), then using tlmgr with sudo -u texlive tlmgr. If $PATH isn't properly set, sudo env PATH="$PATH" /usr/local/texlive/2017/bin/x86_64-linux/tlmgr path add should sort that out (use 20XX according to your version). – Jonathan Y. Jun 19 '17 at 10:31
  • @JonathanY. Not all Linux distros have sudo by default. And I don't honestly see any reason for adding this complication. Moreover, sudo is complicated in various ways and its configuration is highly system and distro dependent, so it is difficult to give instructions. But what is the advantage? I realise it means somebody can't log in as texlive, but I don't see any particular benefit in that. Note that part of the point of my post is that you don't need to specify the 20XX in the path. – cfr Jun 19 '17 at 12:58
  • Well the answer calls sudo several times as it is; the advantage is what you say, but I disagree on the benefit: setting a separate password adds an attack vector plus the potential to lose it / cost to remember it. You could make it random, and use sudo to reset it every time you use tlmgr (which shouldn't be often), but what's the point? Also, setting $PATH a single time is comparable to installing fake packages -- there's no added cost here. – Jonathan Y. Jun 19 '17 at 13:07
  • I'm sorry, if you mean that the work user needn't set their $PATH to include the correct directory in /usr/local/texlive, then I missed that. How so? – Jonathan Y. Jun 19 '17 at 13:10
  • I use tlmgr often. I don't know why you claim I 'shouldn't'. Anyone on a system without sudo will translate the above appropriately. (I doubt I used sudo where I've given it above, but this is primarily a Debian/Ubuntu question, so I gave the code that way here.) The texlive account has fewer privileges than my regular user account. I can easily reset the password if I need to. I don't see any significant increase in risk from managing the installation directly as texlive, which greatly simplifies things. Your last comment is correct, though. (But I seem to have presupposed it....) – cfr Jun 19 '17 at 23:12
  • @JonathanY. Thanks for pointing out the omission. Please see edit above. Note, too, that even if you rarely use tlmgr, you may well need to manage TEXMFLOCAL, which is much more conveniently done by a user who can log in than by one who cannot. Of course, you can manage without this, but it complicates things significantly. Even if all you want to do is install the non-free fonts, it is easier to do it this way. I also think that there is less danger of accidentally modifying the contents of /usr/local/texlive as root this way. You can set up a distinctive prompt for the texliveuser. – cfr Jun 19 '17 at 23:29
  • An unrelated follow-up question on this post: does this setup offer any mitigating factor to the risk (to one's home directory, among other things) presented by running texlive executables (which, presumably, most do with their own user)? Even if we authenticate an image as signed by the tl team, does tlmgr use any cryptography to authenticate updates? Can one easily set up a process that compiles Tex sources as the unprivileged user? – Jonathan Y. Jun 22 '17 at 20:32
  • @JonathanY. No. This offers no additional protection when using TeX Live. It only protects you while installing and updating/maintaining it. If you install malicious binaries, then you are in trouble. However, note that this would require something like pdfTeX itself to be altered, because TeX will not usually allow either arbitrary command execution or changes above the working directory. By default. You can change it to be either stricter or less strict. – cfr Jun 23 '17 at 00:25
  • @JonathanY. For installation/updates, checksums are checked and the checksum list is verified. However, if verification fails, installation continues by default. This can be disabled or enforced using custom options. See tlmgr's manual page for details. – cfr Jun 23 '17 at 00:25
  • @cfr, interesting approach. But, a practical question, do you consider TeXLive (or CTAN for that sake) as being riskier than, e.g., Ubuntu or Debian standard repositories? – gusbrs Jun 29 '17 at 21:33
  • 1
    @gusbrs Yes. But that's not really the point. The point is the general principle of not doing things with higher privileges than necessary. There's a reason I don't write my TeX documents as root: it is entirely unnecessary. Note that when you install programmes from your distro's repositories, installation scripts may well drop privileges for the sake of security. Neither the TeX Live installer nor tlmgr drops privileges. If you run them as root, they do everything as root. – cfr Jun 29 '17 at 22:31
  • 1
    @gusbrs It is left to the user to follow TeX Live's own advice or not, just as it is left to you whether to run other things as advised or not. It isn't a question of the repos being riskier or not. It is a question of it being riskier to ignore upstream's advice. Upstream advise installing without privileges. This is the only sensible advice: privileges are entirely unnecessary, therefore they should not be used. This is a basic strategy: don't do anything with more privileges than necessary. If you must run something as root, drop privileges as soon as possible. – cfr Jun 29 '17 at 22:34
  • 1
    @gusbrs In one sense, of course CTAN and TL are riskier than Debian/Ubuntu standard repositories. CTAN does not scrutinise the packages uploaded. TL does not scrutinise them either. They would not accept anything obviously malicious or obviously inadvertently problematic, but there is no active scrutiny. In another sense, of course the standard repos are riskier because they are the source of software with far more potential for damage. So which kind of risk are you asking about? – cfr Jun 29 '17 at 22:39
  • 1
    @gusbrs You can actually convert your installation to a ownership by a non-privileged user. If you do that, you can run tlmgr without privileges. Basically, create the new user and then run, say chown -Rh texlive:texlive /usr/local/texlive as root or with sudo. Then manage the installation as texlive. – cfr Jun 29 '17 at 22:42
  • @cfr, actually I hadn't taken the thought that deep. I was just thinking of the installation of a regular program trough the repos, let's say texlive itself. But you are correct in pointing the two kinds of risk. – gusbrs Jun 29 '17 at 22:44
  • @cfr, I've been trying this out, and have a small suggestion. In the update section (at least in my settings) if I use su texlive the path is not set appropriately. For that, I have to use su -l texlive, with which I get the environment variables also set. (I did not set TeXLive paths globally, but trough /etc/profile.d). – gusbrs Jul 04 '17 at 21:35
  • @gusbrs What do you mean by not setting them globally? If you set them in /etc/profile.d, they should be set for all users. – cfr Jul 04 '17 at 22:16
  • @gusbrs Thanks for the suggestion about su -l. I've added that even though I'm not sure why it is needed on some systems, because I don't think it will hurt anything even where it is not needed. – cfr Jul 04 '17 at 22:20
  • @cfr, I mean I haven't set the path in /etc/environment, but I guess my terms were not adequate, given that /etc/profile.d indeed sets it for all users. – gusbrs Jul 04 '17 at 22:33
  • @cfr, I'm working within a somewhat common environment: Linux Mint 18.2, which is akin to Ubuntu 16.04. What happened is that, setting the path with /etc/profile.d and changing users with su texlive the path did not come along. I really cannot tell you why. If I logged out and then logged in as texlive, it did work fine. Resorting to su -l sorted out the issue for me. – gusbrs Jul 04 '17 at 22:37
  • I set it in /etc/profile.d, too. But I'm on a different system and different systems will configure things differently. (Actually, 2 systems, but they are both different.) – cfr Jul 05 '17 at 00:50
  • A minor suggestion / request: to help differentiate between the actual TeXLive and the "artificial / workaround" user texlive, could you perhaps rename the user in your guidelines above to, for instance texalive ? – nutty about natty Aug 10 '17 at 08:16
  • Or, will it not work if the username is anything but texlive ? – nutty about natty Aug 10 '17 at 08:53
  • Here's what I did in the end: username texalive but in the mkdir and chown lines kept /usr/local/texlive. – nutty about natty Aug 10 '17 at 09:11
  • Help needed: which tex returned /usr/local/texlive/....... alright while "logged in" to the texalive user in terminal, then typed exit and hit enter and which tex no longer returned anything, also not upon logging back in to texalive. What am I missing?! – nutty about natty Aug 10 '17 at 12:56
  • PS: am testing this on a virtual machine first and I took a snapshot right after the installation completed and I updated the PATH's, so I can always return to the machine state where which tex still worked. – nutty about natty Aug 10 '17 at 13:00
  • Thanks for that! -- Any idea why the successful installation (as evidenced by which tex) could have gone missing (?) - no response to which tex - upon executing an exit command (which here roughly triggers a change of user from tladmin back to the original user), for example, in the very same shell/command line instance in my more recent comment/question? – nutty about natty Aug 10 '17 at 14:30
  • which tex also returns nothing if (from the virtual machine state freshly after the successful install) I switch with su main-user to the main-user (and also does not return when I switch back again with su tladmin to the "texlive" user). – nutty about natty Aug 10 '17 at 16:54
  • Ok, I thought I managed to solve it (or at least find a viable workaround), but apparently not quite yet: if I execute the three export commands again (e.g. not as tladmin but as the main/normal user), which tex, man tex, etc work. However, if I close that terminal and start a new one, things are reset and I need to export again. What am I doing wrong(ly)? – nutty about natty Aug 10 '17 at 17:13
  • SOLVED, I think. Added the three lines to $HOME/.profile of the main/normal user (cf., for instance, http://www.tug.org/texlive/doc/texlive-en/texlive-en.html#x1-310003.4.1). Saved. Logged-out-and-back-in. which tex works. – nutty about natty Aug 10 '17 at 18:52
  • @nuttyaboutnatty You should be able to set those system-wide, as I did, in /etc. However, exactly what you need to change in /etc is system-dependent. For me, it means adding a new file in /etc/profile.d but, for you, it might require something different. It depends how your Linux distro configures PATH. You should not set MANPATH etc. on any recent distro of which I'm aware - only PATH. However, changes in /etc won't take effect until your next login. (I don't know what that means on a virtual machine.) – cfr Aug 10 '17 at 23:14
  • The check for 'normal' users in the profile script if [ \whoami` != "root" ]; then ... fishould rather be checking which user id is used, i.e.if (( $EUID == 0 )); then ... fi` (requires bash). This is more portable and more secure as the su is not always called root, but it has always 0 as id. – Martin - マーチン Aug 11 '17 at 07:50
  • @Martin-マーチン What's the difference between EUID and UID? Is EUID available everywhere UID is? – cfr Aug 11 '17 at 14:44
  • @Martin-マーチン I guess $UID would be better since EUID is newer and I'm not clear whether it is supported everywhere. (E.g. long-term support editions of RHEL etc., BSD etc.) So maybe if [ $UID != 0 ]; then ... fi ... – cfr Aug 11 '17 at 14:47
  • @cfr I am not 100% sure right now, my Linux knowledge is very dependable on my notes. I remember looking it up and that it is now the recommended practice. It should be available in the new kernels, and since we're talking about installing the latest texlive version, we can assume that the user had an reasonably updated system. It certainly works on Centos, Ubuntu, and I think I tried it on Suse. Whoami is not a good idea, because that's a script calling the $USER variable and not a shell native. That basically defeats the purpose of portability you are trying to achieve. – Martin - マーチン Aug 11 '17 at 14:55
  • @Martin-マーチン I agree about whoami. I've edited above to use UID instead. UID is available on BSD-like systems and will be in RHEL, whereas I'm not certain about EUID, which only seems to have been introduced to POSIX circa 2013. There's no guarantee that a new TL means a new OS. One reason people install vanilla TL is precisely that their distro's packages supply only a very outdated version. So, if anything, this is more likely relevant to people on older systems. – cfr Aug 11 '17 at 15:00
  • And one more things I noticed. You don't necessarily have to install it in /usr/local/, it works everywhere. You can keep your installation completely local. I do it that way, because I'm using this approach for many other programs I need to install. As long as every user can read and X it, it's fine. You can go a bit further and simply add the users who should be allowed to use it to a group. Then you can get rid of the world permissions currently necessary. – Martin - マーチン Aug 11 '17 at 15:01
  • @Martin-マーチン Yes, you can. But it makes things much easier not to do that. People who understand their systems well enough to cope with the additional complications do not need my step-by-step instructions. There isn't actually any security reason not to have world permissions, really. At least, no reason that doesn't apply to every other programme. And there is no security advantage to avoiding /usr/local. – cfr Aug 11 '17 at 15:03
  • Sorry for the inappropriate edit. I thought you could review it before it was acceppted. – Arch Stanton Aug 23 '17 at 07:48
  • @ArchStanton I didn't even know you'd edited this answer. – cfr Aug 23 '17 at 22:08
  • @ArchStanton I'm not sure if I saw it or not, actually, but don't worry about it. I just put a banner up to (try to) stop people keep editing it in ways that make it much more distro- or distro-version specific. If people leave me a comment, I can figure out whether I need a 'if you have X, do Y, but if you have A, do B' or whatever. This is how the adding-new-user stuff turned out to go, whereas if it had just been 'updated', it wouldn't have worked on other systems (including mine!). Different distros and different installations of the same distro can be very, very different. – cfr Aug 23 '17 at 22:18
  • Out of curiosity, what's the use of the comment in /etc/profile.d/texmf.sh? – Arch Stanton Jun 27 '18 at 23:37
  • @ArchStanton I just put it here when writing the answer so that the name of the file is tied as closely as possible to the content. I don't have it in /etc/profile.d/cfr_texlive.sh on my system, which is the equivalent. – cfr Jun 28 '18 at 00:40
  • Thanks. I asked because I saw other files in /etc/profile.d/ with their full name in the first line as a comment. I thought it was to distinguish them if they are concatenated. – Arch Stanton Jun 28 '18 at 01:01
  • @ArchStanton Well, that too. Lots of files have this just for tracking, I think. If a file ends up in the wrong place it can tell you where home is. A bit like teaching small children their addresses. – cfr Jun 28 '18 at 01:10
  • I have just installed TL2019 on a Fedora 30 box. I had to run sudo chmod 755 /usr/local/texlive/ in order to have [ -d /usr/local/texlive/2019/bin/x86_64-linux ] return true (which tex was failing because the test in /etc/profile.d/texlive.sh returned false). /usr/local/texlive/ only had rwx------ permissions, while every other directory in /usr/local/ had drwxr-xr-x permissions (755 in octal). – Arch Stanton May 18 '19 at 16:21
14

A paper about installing TeX Live 2011 on Ubuntu and other GNU/Linux distributions can be found on

ArsTeXnica, vol. 10 (in Italian)
TUGboat, vol. 32-1 (issue 100) (in English)
Die TeXnische Komödie, issue 3/2011 (in German)

Thanks to Karl Berry and Barbara Beeton for the revision of the TUGboat version, and to Heiko Oberdiek and Herbert Voß for the German translation.

The papers are, up to now, available only to members of GuIT, TUG, and Dante, respectively, but will be public in due time.

Note: the Italian and English versions are about TeX Live 2010, but it's sufficient to change 2010 into 2011 in all the steps.

egreg
  • 1,121,712
  • it seems that access to the English version is restricted to tug members – David LeBauer Dec 23 '11 at 00:20
  • Yes, as are also the other versions. TUG discloses articles to everybody after one year, IIRC. – egreg Dec 23 '11 at 00:29
  • @egreg I have a question about perl-tk. In your guide you state to install it using Synaptic. Silke, in his answer above, says to write sudo apt-get install perl-tk --no-install-recommends. I wanted to know if it is the same thing. – Marco Jan 25 '16 at 13:26
  • 1
    @Marco Yes, that should be the same, as Synaptic is an interface to apt. – egreg Jan 25 '16 at 14:23
9

I have successfully installed TeXLive on Ubuntu 11.10 on a 64bit machine.

I have condensed the steps linked to in frabjou's answer, which, while the instructions are clear, may leave many *buntu users wondering "how do I change the PATH variable?"

wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
tar -xvf install-tl-unx.tar.gz
cd install-tl*
sudo ./install-tl
  • at prompt, enter "i" to install
  • change PATH, I did so by editing ~/.bashrc:

    • 64 bit

      # PATH=/usr/local/texlive/2011/bin/x86_64-linux:$PATH
      cat "export PATH=/usr/local/texlive/2011/bin/x86_64-linux:$PATH" >> ~/.bashrc
      
    • 32 bit:

      cat "export PATH=/usr/local/texlive/2011/bin/i386-linux:$PATH" >> ~/.bashrc
      

caveat see the tug instructions for more details; e.g. if TeXLive 2011 has been previously installed, it needs to be removed

4

Fake packages

Following up Silex's excellent write-up: I have put a fake package texlive-dummy created by the equivs-build process into my PPA. (Package source.) If you are on Ubuntu 13.04, the following will provide the necessary dependencies without having to generate a package:

add-apt-repository ppa:krlmlr/ppa
apt-get update
apt-get install texlive-dummy

I intend to update this package to more recent versions of Ubuntu.

See Scott's answer for a much better solution.

krlmlr
  • 12,530
3

It should be noted that there is now a much easier way to install up to date versions of TeXLive. There are now official backports of newer versions of TeXLive, as detailed here.

This gets you to at least 2012, and it looks like newer versions of Ubuntu have 2013, so you can probably pull this package out of their repertories without damaging anything, though I wouldn't swear by that and you should consult an Ubuntu expert first.

Canageek
  • 17,935
  • 1
    texdoc,tlmgr which get's automatic updates for all new packages will be missing with 2012 backports and even distro specific latex packages are very old and cannot updated with tlmgr. Hence vanilla texlive installation is the way to do for taking advantage of full power of texlive distro and being latest. – texenthusiast Dec 18 '13 at 03:10
  • @texenthusiast Ah, I didn't know that. Looking at the changelog once you get the newest version of ubuntu they are keeping the package up to date at least. Should I delete my answer? – Canageek Dec 18 '13 at 03:34
  • actually backports was mentioned by naught101 user in comments. So I think backports is not too much advisable compared to the vanilla install if possible sorry to say delete the answer. But some people prefer to be with ubuntu's ppa also instead of being over latest. finally take your decision. – texenthusiast Dec 18 '13 at 03:39
3

I ended up writing a guide for someone else that expands on the excellent answers here, so I will post it here as well. The first section is roughly equivalent to cfr’s answer.

Installing TeX Live on Debian/Ubuntu

You do not need to install TeX Live as root, although that will work. The reason you might not want to is security: if you install as root, every package install script runs sudo root.

If you already have a copy of TeX Live installed, you should remove it with apt. You might also want to sudo rm -r /usr/local/texlive if it exists and start fresh.

You can create a new user and group that owns only the TeX installation with

sudo adduser --system --group --home-dir /usr/local/texlive tex

This will create a new user and group account that cannot log in and owns only the local TeX Live directory. You can, however, run commands as sudo -u tex. The sole purpose of this account is to run TeX installers and updates. That way, they only have permission to read and modify your TeX distribution.

Having done this, you want to make sure that only TeX can add and remove files in the TeX directory, but everyone else can use cd and ls on it.

sudo chown tex:tex /usr/local/texlive
sudo chmod 755 /usr/local/texlive

You can now install TeX Live, as tex, to this new directory that TeX owns. From the directory where you unpacked the TeX Live installer:

chmod 755 install-tl
sudo -u tex -E ./install-tl

The option -u tex means run as the user tex, and -E means preserve the environment variables, for example LANG to determine the language. By default, the installer should put the files in the new directory you just created, /usr/local/texlive/. Since tex owns this directory, it can.

You don’t need to use sudo to run commands like lualatex or pdflatex. You’d run those from your regular account. The only time you need to run as tex is when you’re updating the TeX installation, which tex owns.

Updating Your Configuration

First, you need to add your TeX Live directories to your PATH, MANPATH and INFOPATH environment variables, ahead of the system directories. Reposting from above: you can save the following to a file named /etc/profile.d/texlive.sh and it will load the next time you open a shell.

PATH=/usr/local/texlive/2020/bin/x86_64-linux:$PATH
export PATH
INFOPATH=/usr/local/texlive/2020/texmf-dist/doc/info:$INFOPATH
export INFOPATH
MANPATH=/usr/local/texlive/2020/texmf-dist/doc/man:$MANPATH
export MANPATH

Update this if you are running a version other than 2020, of course.

If you exec bash -login to reload your environment, latex --version should tell you that it was installed from TeX Live, not your distribution. You should also be able to run man latex and info latex.

The command to update your tex installation is long and annoying, but you can create an easy-to-remember alias. The command for this is:

alias update-tex='sudo -u tex -E $(which tlmgr) update --self --all'

You would need to add it to your profile (either the file in /etc/profile.d, ~/.profile, or ~/.bash_profile if it exists) as well as whichever of ~/.bashrc, ~/.cshrc, ~/.kshrc, etc. you use to set it for non-login shells. You could also set your aliases in a file such as ~/.sh_aliases and source it within your *profile and *rc files.

The next time you open a command prompt (or refresh it with exec bash -login), you can update by typing update-tex.

Installing Non-Libre Fonts from CTAN

There’s a bit of a gotcha if you want to install getnonfreefonts from TUG. You might be tempted to install to your user directory, because that’s the only way that works out of the box. You want to install as --sys, not --user. Installing 8-bit fonts as a user is a trap. If you install as user, the installer will run updmap as a user, which will create a font map in your user directory. That will appear to work at first, but it will hide the system map from you and not be updated when you update the system map, so your map file will get more and more out of date.

You have to use a little trick to install it. The command you have to run for the installer to work is

sudo -u tex -E --preserve-env=PATH $(which texlua) install-getnonfreefonts

This command creates a perl script to install the fonts, which you run with

sudo -u tex -E --preserve-env=PATH $(kpsewhich getnonfreefonts.pl) --sys --all --refreshmap --http

Installing Other Local Files

Sometimes, you might want to download TeX files that are not available as TeX Live packages, such as your publisher’s class file or the Type 1 fonts for Georgian. You usually want to put these in a subdirectory of TEXMFLOCAL (/usr/local/texlive/texmf-local/) . rather than TEXMFHOME (~/texmf/) . You can copy a directory with sudo -u tex cp -r. After manually installing new files, run

sudo -u tex -E $(which texhash)
sudo -u tex -E $(which updmap-sys)

This makes sure your indices and map files are up to date.

If you only need them for one project, you can copy them to your project directory.

Installing and Using Fonts

You can install new fonts for your user account by saving them to ~/.fonts/, or for everyone by saving them to /usr/local/share/fonts/.

You might want to add your TeX tree to the system font paths. (Or even need to, for XeTeX to consistently find them.) The file with the script to do this is texlive-fontconfig.conf, and you can enable it by creating a symbolic link to it in the directory /etc/fonts/conf.d/:

sudo ln -s /usr/local/texlive/2020/texmf-var/fonts/conf/texlive-fontconfig.conf /etc/fonts/conf.d/09-texlive2020.conf

I additionally created a file with the same format to index the fonts in my TEXMFLOCAL tree. I saved the following as /etc/fonts/conf.d/09-texmf-local.conf:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <dir>/usr/local/texlive/texmf-local/fonts/opentype</dir>
  <dir>/usr/local/texlive/texmf-local/fonts/type1</dir>
  <dir>/usr/local/texlive/texmf-local/fonts/truetype</dir>    
</fontconfig>

I gave these files a low number, such as 09, so that they will be searched before the system directories. The fonts in my TeX directories are usually more up-to-date.

Both XeTeX and LuaTeX should automatically refresh their databases the next time you request a font it doesn’t know about, but you can manually make them do it with

sudo fc-cache -fsv
luaotfload-tool -f -u -p -v

Other Optional Stuff

Some people recommend making a dummy apt package to prevent a second version of texlive from being automatically installed. I personally have not had that problem.

Davislor
  • 44,045
  • If you put the path in /etc/profile.d/texlive.sh as shown above, then instead of the long alias to use tlmgr, you can just say sudo -i tlmgr and the profile will still apply. – musarithmia Oct 07 '22 at 00:48
  • @musarithmia That’s a good tip. I have the alias so I can just type update-tex anyway. – Davislor Oct 07 '22 at 03:43
2

This is intended as a complement to cfr's answer (https://tex.stackexchange.com/a/187379/105447) for those who wish the convenience of the GUI for the use of tlmgr.

If you login in the terminal with su texlive you won't be able to run tlmgr --gui because the user texlive is not allowed by default to start a gui in your regular user's session (I'm not sure this is the best terminology for that). But you can allow it explicitly. For that, you should first run, as your regular user:

xhost +SI:localuser:texlive

And then login as texlive and run tlmgr:

su -l texlive
tlmgr --gui

If, besides that, you want to setup a launcher, you could add xhost +SI:localuser:texlive at the end of your ~/.profile (or equivalent in your system), logout, login back, and then create ~/.local/share/applications/tlmgr.desktop with the following content:

[Desktop Entry]
Version=1.0
Type=Application
Name=TeX Live Manager
Comment=Manages TeX Live packages
Icon=system-software-update
Exec=gksu -d -u texlive -D "TeX Live Manager" '/usr/local/texlive/2017/bin/x86_64-linux/tlmgr --gui'
Categories=Office;
Terminal=false

The path to tlmgr should be set as appropriate in your system (in doubt, use which tlmgr). Furthermore, gksu must be set with gksu-properties, setting "authentication mode" = "su".

gusbrs
  • 13,740