How to run TeX from the command line interface in Linux

Even though I can find this command hiding somewhere on the internet, I though it might be useful to have it up here for the LaTeX community in general.

How does one run TeX from the command line interface (Terminal) in Linux? Are there any required parameters? What if the command is part of a bigger script, how does the script know when the TeX processing is done to continue with any subsequent actions needed? Is there a clear manual for this somewhere?

A starting point might be:

``````pdflatex [options] filename.tex
latex [options] filename.tex
xelatex [options] filename.tex
``````
• Hi! In my opinion, your question does not seem to me to be really good. There are couple reasons: (1) You answer the question in the question text. (2) You obviously somehow know the answer and you don't ask "for yourself", but in the current shape, I don't think it can help anybody. (3) Please note that most of the "broad" questions like this one are posted after some discussion in the community, usually on TeX - LaTeX Meta or in chat, in both of which you're most welcome ;) (Notice that I didn't downvote it since I think -1 is enough.) – yo' Dec 17 '12 at 9:38
• @tohecz I need to mention how much I like what you have done here. Most people do not take the time to comment when they downvote a question. Without even downvoting it you explained very well why you think the question is bad and in such a friendly manner! I wish this happened more often. – Vivi Dec 17 '12 at 10:07
• Have to tried `man pdftex`? This is Unix, you know. – Reinstate Monica - M. Schröder Dec 18 '12 at 7:47
• I tried XeLaTeX document and got `kpathsea: Running mktexfmt XeLaTeX.fmt I can't find the format file `XeLaTeX.fmt'!` and trying to use man XeLaTeX I got `no manual entry for XeLaTeX` so for people are starting to learn how to use TeX & friends without a GUI, answers to this would be very useful – Sergio Parreiras Sep 13 '14 at 15:03
• For a question considered by some to be 'not really good' it just received over 10 000 views, so it seems that a lot of people are interested in this at least. – McGafter Oct 27 '15 at 9:29

You're right: `latex filename.tex` and the other above command are means to run a flavor of TeX from the command line.

They don't really require parameters, but you could also have a look at the configuration of GUI software like Texmaker, or type in the command line `latex --help` to show the complete list of available options. For example, the option `-interaction=nonstopmode` makes latex not stopping on every error...

These programs run in a single shot: they will not take action. For that, in Linux, you could write a Makefile that will arrange the required compilation steps, as shown here or here.

For the manual, you could try `man latex`, but I don't think that it is a good answer or question. The above commands run Latex/Pdflatex/... the same ways that a GUI editor will do.

First, make sure you install the latex package by executing the following command :

``````sudo apt install texlive-latex-base
``````

Second, execute :

``````latex Filename.tex
``````
• And for all the beginners reading this: you probably have `latexmk` or `arara` installed, use one of them. – Oleg Lobachev Dec 13 '19 at 23:46