Check the PATH of your Mac with echo $PATH

Aug 31, 2010 - Leave a Comment

terminal Anytime that you run a command through the Terminal directly by a command name like ls or dscacheutil, your Mac is looking through a series of directories for that command to exist. This list of directories is called the PATH, and it’s a carry over from the unix underpinnings of Mac OS X.

As you may have guessed, checking your PATH in Mac OS X is the same as it is in most other unix variants, so if you come from a linux or unix background you can use the same syntax to check the path and see what directories are included in the currently active path of the shell.

To check this, you just need to use the echo command at the terminal prompt like the following:

echo $PATH

Executing that command successfully will result in seeing something like the following:

$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

The directories listed are those that are searched for commands. So the next time someone asks you if a directory is in your path, now you know where to look and how to find out.

Terminal in OS X

This can also be helpful when troubleshooting commands not being found and other related error messages to command execution, because if a bin path is not listed then it may need to be added before the shell will know where to look to execute the command in question.

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: Manish Patel in Command Line, Mac OS X

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates