(Please forgive me if this question is so simple or looks stupid)

I want to run Latex on Ubuntu. It is said that we use similar commands as those used in Windows OS, (e.g. pdflatex file.tex, ...) but, where to type this command line?

I mean, in Windows OS, after start cmd, we use "d:" to go to "d" disk, "cd/myTex" to go the folder myTex [which contaning Latex-related files (file.tex, *.sty files, ...)], and then after the "d:/myTex", we type "pdflatex file.tex" + [Enter] to compile the file.tex. Do I need to find the directory of the folder contaning my Latex-related files as done in Windows OS? and type "cd" +... Directories in Ubuntu are long and hard to find, something like "/dev/sda" ...

Now I am storing file.tex in the folder myTex of "Devices/Local Disk".

I looked for advices but achieved comments from the "final" step only, i.e. "please type pdflatex file.tex" ... (I guess that this is a very common task then noone asks and no answer is stored online).

Thank you very much for your kind helps.

  • Press Ctrl+Alt+T to open a terminal. Use cd /path/ to move to the working directory (/path/ must be replaced with the actual path to your directory). May 15, 2014 at 14:41
  • Typically your Documents folder would be in cd /home/YourUser/
    – Holene
    May 15, 2014 at 14:43
  • 5
    This doesn't really seem to be a TeX question, but a basic Linux question.
    – Alan Munn
    May 15, 2014 at 14:47
  • 3
    If you are not used to using the Terminal, is there a reason you are not looking to use LaTeX via a GUI?
    – Joseph Wright
    May 15, 2014 at 14:47
  • 1
    You don't need to write any command in Linux to compile LaTeX. Use Kile and problem solved.
    – Charlie
    May 15, 2014 at 15:55

2 Answers 2


Yes, it is required to run the command in the same directory as the file.

Try searching for your file using find -iname file.tex. Then cd to the resulting directory and run pdflatex file.tex once you are over there.

Alternatively, you could browse to the file location using the folder explorer and run a terminal window from there.

Note that if your file is on a different hard disk partition than your home directory, you will need to mount that partition first, which is a different topic in itself.

  • So, such a folder should be put in the Home Folder to be easily manipulated.
    – NguyenDV
    May 15, 2014 at 16:22
  • @Nguyen Either move the folder to your home directory, or create a permanent mount directory of the other partition. You might find it useful to read this page. That is way outside the scope of TeX as pointed out by the comments on your question.
    – Tymric
    May 15, 2014 at 16:28
  • 2
    That find command will not work unless file.tex is beneath the current directory or in the current directory. So if the file is on another disk, as seems to be the case, and you open a fresh terminal, the command is extremely likely to return no results or wrong results. Also, if somebody happens to have a lot of stuff in their home directory, it will take ages to return nothing.
    – cfr
    May 16, 2014 at 2:07

Read these instructions on how to start a Terminal on Ubuntu (there are instructions for various Ubuntu-flavours). The latex command should work in that terminal if you have it installed on the system.

On Linux, personal files are usually stored in your home folder. The terminal will open there by default, so in most cases it should be enough to type cd myTex and then latex example.tex. Note that the terminal has a handy tab completion, which makes directory navigation fast and easy (type the first letters of the name and hit TAB for autocompletion).

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