Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm testing an app that uses the System temp Directory. Inside of the app, there is some call to a Cocoa function to query this. Is there a way for me to query for this directory name outside of having to write a Cocoa app of my own? Possibly a command that I can issue in Terminal?

share|improve this question
I found this answer great plus it works on Linux platforms too (probably not a huge concern for you, I realise): – Tom Saleeba Oct 22 '15 at 9:46
up vote 11 down vote accepted

Just type this command into Terminal. With zero arguments it'll print the names and values of variables in the environment.

Alternative with a bit more typing:

echo $TMPDIR
share|improve this answer
Thanks. What a weird path - /var/folders/iz/izqn2b5MF-iz9oL0CURH1U+++TI/-Tmp-/ – bpapa Nov 13 '10 at 20:32
This is not a good answer, since this env variable points to different directory every time a different process is invoked. It is made to let each process freely write into a "temp" directory, without worrying that it might overwrite (or read by mistake) something another application wrote. – Motti Shneor Apr 4 at 10:08

OS X has Python pre-installed, though not necessarily a fresh Python; but this is not cutting-edge stuff.


Open a terminal

cat >
import tempfile
print tempfile.gettempdir()

Credit to nosklo

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.