9

So, I'm running linux Mint (but I guess the same applies to Ubuntu) and as is common knowledge, their TeX distribution tends to be slightly outdated. Now I can't have none of that and decide to install it with the install-tl from the TeXlive homepage. Somehow, I cannot install it as a normal user (this I find normal as it is installing in the root directory), so I proceed to install TeXlive

sudo perl ./install-tl

and add the paths to .bashrc. All is well and my TeXlive installation works. Except for the texhash option. Running it as a normal user is no problem, except that I installed TeXlive as root, and so running texhash as normal user doesn't do anything (directory not writable. Skipping...). No problem I think, I'll just do it as root. But somehow texhash isn't installed for root.

Now, texhash is somehow connected to updating the directory tree, but I don't really know what it does. I use it on my ~/texmf/ folder to add my packages to a global path (I think), but when looking at info for this question I see in a comment for this question that this is apparently not needed, though I don't understand what I'm to do now.

So if I'm not adding new packages from CTAN or updating, I really don't need texhash and all is good?

To summarize: I'd like to know:

  • Why should I need texhash?
  • Can I avoid installing as root on linux Mint/ubuntu (here they say you don't have to be root, that it's even discouraged)?
  • Should I somehow install texhash for root?

I realize this might be a vague question at best, but I didn't find an answer I readily understood, so I'd appreciate any thought on this.

6
  • 3
    try adding alias sudo='sudo env PATH=$PATH' to your .bashrc (that's what helped here, on ubuntu)
    – henrique
    Mar 16, 2012 at 20:28
  • 1
    sudo mktexlsr, as for all commands you're supposed to run with administrator privileges, after having done as henrique suggested.
    – egreg
    Mar 16, 2012 at 20:29
  • Fantastic, the alias thing worked. What is the difference between running mktexlsr or texhash?
    – Jóhann
    Mar 16, 2012 at 20:31
  • 1
    BTW here's where I learned that. (There's no rationale, it's just "an annoying function of sudo on ubuntu" :)
    – henrique
    Mar 16, 2012 at 20:37
  • 1
    mktexlsr and texhash are the same thing, the later is a symlink to the former.
    – mpg
    Mar 17, 2012 at 8:46

2 Answers 2

8

Why should I need texhash?

TeX has lots of tiny files, .tfm files for instance. So finding something involves a lot of disk activity. Texhash looks once and remembers the locations of all the files in a simple single-file database, and then when TeX programs need to find those files the only reading is of that database. Roughly, it remembers where your TeX-relevant files are.

The downside is that when you add or move files you need to run texhash.

Can I avoid installing as root on linux Mint/ubuntu (here they say you don't have to be root, that it's even discouraged)?

I have installed as not-root on Ubuntu. (At the moment, I use the debian packages though.) If you have a one-person system probably root is the easiest.

Should I somehow install texhash for root?

What does whereis texhash say? (Mine says /usr/bin/texhash.) What are the permissions? For comparision, mine says this.

ftpmaint@millstone:~$ ls -l /usr/bin/texhash
lrwxrwxrwx 1 root root 8 2011-05-25 08:01 /usr/bin/texhash -> mktexlsr
ftpmaint@millstone:~$ ls -l /usr/bin/mktexlsr
-rwxr-xr-x 1 root root 6885 2011-04-10 15:52 /usr/bin/mktexlsr
3
  • When I run whereis texhash I get texhash: That's not normal is it? But it seems to aknowledge it, as when I try texhash --version The terminal presents me with this wealth of information: texhash $Id: mktexlsr 23151 2011-06-27 22:27:02Z karl $ kpathsea version 6.0.1 Copyright 2011 Karl Berry & Olaf Weber. License LGPLv2.1+: GNU Lesser GPL version 2.1 or later <http://gnu.org/licenses/lgpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Where is it?
    – Jóhann
    Mar 16, 2012 at 20:28
  • It's probably on /usr/bin/texlive/2011/bin/<e.g.i386-linux>/ try instead a which texhash (also check this answer to "How can I call TexLive in Ubuntu?")
    – henrique
    Mar 16, 2012 at 20:43
  • Mine is in /usr/local/texlive/2011/bin/i386-linux and the permissions are: lrwxrwxrwx 1 root root 8 2009-08-15 17:48 texhash -> mktexlsr -rwxr-xr-x 1 root root 7479 2011-06-27 22:28 mktexlsr
    – Jóhann
    Mar 16, 2012 at 21:35
5

I use it (texhash) on my ~/texmf/ folder to add my packages to a global path (I think)

That's not what texhash does. It builds one index for each tree that is configured to use an index. The trees are independent, each with its own index, so files in your ~/texmf are always personal. The index is useful, as Jim explained, to avoid searching for files on the disk, which would be pretty slow for big trees (last time I checked, the main tree was like 50.000 files in 5.000 directories). However, ~/texmf usually does not contain that many files, so by default it is configured not to used an index (starting with TeX Live 2007).

Besides, even if ~/texmf was using an index, you'd still be able to refresh it without being root by running texhash ~/texmf since the index is written at the root of the tree.

Why should I need texhash?

So, short answer: if all you're doing is add files to ~/texmf you simply do not need to run it.

Can I avoid installing as root

Sure you can. Just choose a TEXROOT you have write permission to. This can be done in two ways: as root, grant write permission to you user on /usr/local/texlive and install there as a user. Or, install somewhere in your home, like ~/usr/texlive or whatever you like.

Here on my Debian machine, I haven't installed TeX Live as root since a while, and never had the slightest problem with that. Besides, the page you're linking to belongs to TeX Live's official documentation, if it says you don't need to be root, you sure can believe that.

Should I somehow install texhash for root?

There is no such thing as "installing". Just make sure texhash is in root's PATH or export your user's PATH as suggested in henrique's comment (probably the most convenient option) or call it with full path, like sudo /usr/local/texlive/2011/bin/x86_64-linux/texhash.

1
  • With the former option, would I just make the directory /usr/local/texlive and grant permission as root before installing (the install-tl doesn't mind the directory being existent?)? Is the second option discouraged? I've seen something about the structure of linux directories being the way they are for a reason, and as user who doesn't know what he's doing, for the love of god don't mess with the structure. Could I just put the installation in my home directory and change the paths accordingly?
    – Jóhann
    Mar 17, 2012 at 11:09

You must log in to answer this question.

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