# How can latex and pdflatex be both symbolic links to same executable (pdftex) and not behave the same?

When I run

``````\$ latex my_doc.tex
``````

and

``````\$ pdflatex my_doc.tex
``````

it works, and when I run

``````\$ pdftex my_doc.tex
``````

it doesn't work.

The thing is I noticed that both `LaTeX` and `pdflatex` commands are symbolic links to the same `pdftex` executable. That is,

``````\$ which latex pdflatex pdftex
``````

yields

``````/usr/bin/latex
/usr/bin/pdflatex
/usr/bin/pdftex
``````

and

``````\$ ls -l /usr/bin/latex /usr/bin/pdflatex /usr/bin/pdftex
``````

yields

``````/usr/bin/latex -> pdftex
/usr/bin/pdflatex -> pdftex
/usr/bin/pdftex
``````

So how is it possible that commands being symbolic links to a same executable do not behave in the same way ?

Thanks.

I have `Ubuntu 12.10` with TeXLive-full 2012.20120611-4 installed.

-
`pdftex` is a pdf variant of "plain TeX", that's why you get errors compiling your document with it. –  karlkoeller Jul 17 '13 at 15:18
BTW: Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. –  karlkoeller Jul 17 '13 at 15:19
My question is, perhaps, more a 'linux command' thing than a 'TeX engine/format' thing (I don't know). That is, how is it possible that LaTeX knows when I type latex or pdftex at the command prompt, while both commands point at the same executable? –  Martin G. Jul 17 '13 at 15:30
Thanks karlkoeller for the welcome ! I will have a look at the starter guide shortly. –  Martin G. Jul 17 '13 at 15:33

Programs get passed `argv[0]` ie the name by which they are called as well as any explicit following arguments and they can, and do test this and act accordingly. Basically if you make a symbolic link or copy of a web2c tex executable then it acts like `tex &zzz` where `zzz` is the name of the copy or link.
@karl: `argv` is a parameter of the `main` function (programming level) which stands for arguments vector and contains the values of the command line arguments. `argv` is guaranteed to have at least one element, which is the name of the program. `argc` is another parameter which holds the argument count, so when `argc > 1`, the program has arguments to be processed. The logic explained by David is: when `tex` runs, it looks for the value on `argv[0]` and act accordingly. It's actually a cool trick. `:)` –  Paulo Cereda Jul 18 '13 at 12:05
@Paulo Thanks for the explanation. I know what `argv` and `argc` are 'cause I programmed in C, but I didn't know that this is the way in which TeX-related executables are called. The problem is that I don't speak English too much well and sometimes I have difficulties to understand David's words... –  karlkoeller Jul 18 '13 at 14:02