{
	"id": "7683e044-5728-47a6-8606-e936db3bf7f4",
	"created_at": "2026-04-06T00:11:19.378449Z",
	"updated_at": "2026-04-10T13:11:45.887623Z",
	"deleted_at": null,
	"sha1_hash": "4eb5c7d1a7592dfbbe51f39e8fa6778a25389526",
	"title": "MacOS – Set / Change $PATH Variable Command",
	"llm_title": "",
	"authors": "",
	"file_creation_date": "0001-01-01T00:00:00Z",
	"file_modification_date": "0001-01-01T00:00:00Z",
	"file_size": 167233,
	"plain_text": "MacOS – Set / Change $PATH Variable Command\r\nBy Vivek Gite\r\nPublished: 2013-08-25 · Archived: 2026-04-05 21:56:36 UTC\r\nI need to add dev tools (such as JDK and friends) to my PATH. How do I change $PATH variable in OS X 10.8.x?\r\nWhere does $PATH get set in OS X 10.8 Mountain Lion or latest version of macOS?\r\nTutorial details\r\nDifficulty level Easy\r\nRoot privileges No\r\nRequirements macOS terminal\r\nCategory Linux shell scripting\r\nPrerequisites Apple macOS/OS X with bash\r\nOS compatibility BSD • Linux • macOS • OS X • Unix\r\nEst. reading time 3 minutes\r\n$PATH is nothing but an environment variable on Linux, OS X, Unix-like operating systems, and Microsoft\r\nWindows. You can specify a set of directories where executable programs are located using $PATH. The $PATH\r\nvariable is specified as a list of directory names separated by colon (:) characters.\r\nMacOS Print $PATH Settings\r\nTo print the current settings, open the Terminal application and then printf command or echo command\r\necho \"$PATH\"\r\nOR\r\nhttps://www.cyberciti.biz/faq/appleosx-bash-unix-change-set-path-environment-variable/\r\nPage 1 of 4\n\nprintf \"%s\\n\" $PATH\r\nHere is what I see\r\nFig.01: Displaying the current $PATH settings using echo / printf on OS X\r\nmacOS (OS X): Change your PATH environment variable\r\nYou can add path to any one of the following method:\r\n1. $HOME/.bash_profile file using export syntax.\r\n2. /etc/paths.d directory.\r\nMethod #1: $HOME/.bash_profile file to set or change $PATH under macOS\r\n1. Open the Terminal app on macOS.\r\n2. The syntax is as follows using the export command to add to the PATH on macOS:\r\nexport PATH=\"$PATH:/new/dir/location1\"\r\nexport PATH=\"$PATH:/new/dir1:/dir2:/dir/path/no3\"\r\n3. In this example, add the /usr/local/sbin/modemZapp/ directory to $PATH variable. Edit the file\r\n$HOME/.bash_profile, enter:\r\n$ vi $HOME/.bash_profile\r\nOR\r\n$ nano ~/.bash_profile\r\n4. Append the following export command:\r\nexport PATH=\"$PATH:/usr/local/sbin/modemZapp\"\r\n5. Save and close the file when using vim/vi as a text editor by pressing the Esc, type :wq and press the\r\n[Enter] key. Then, to apply changes immediately enter the following source command:\r\n$ source $HOME/.bash_profile\r\nhttps://www.cyberciti.biz/faq/appleosx-bash-unix-change-set-path-environment-variable/\r\nPage 2 of 4\n\nOR\r\n$ . $HOME/.bash_profile\r\n6. Finally, verify your new path settings, enter:\r\n$ echo \"$PATH\"\r\nSample outputs:\r\n/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/sbin/modemZapp\r\nMethod #2: /etc/paths.d directory\r\nApple recommends the path_helper tool to generate the PATH variable i.e. helper for constructing PATH\r\nenvironment variable. From the man page:\r\nThe path_helper utility reads the contents of the files in the directories /etc/paths.d and\r\n/etc/manpaths.d and appends their contents to the PATH and MANPATH environment variables\r\nrespectively.\r\n(The MANPATH environment variable will not be modified unless it is already set in the environment.)\r\nFiles in these directories should contain one path element per line.\r\nPrior to reading these directories, default PATH and MANPATH values are obtained from the files\r\n/etc/paths and /etc/manpaths respectively.\r\nTo list existing path try the ls command. For example:\r\n$ ls -l /etc/paths.d/\r\nSample outputs:\r\ntotal 16\r\n-rw-r--r-- 1 root wheel 13 Sep 28 2012 40-XQuartz\r\nYou can use the cat command to see path settings in 40-XQuartz:\r\n$ cat /etc/paths.d/40-XQuartz\r\nSample outputs:\r\n/opt/X11/bin\r\nTo set /usr/local/sbin/modemZapp to $PATH, enter:\r\nsudo -s 'echo \"/usr/local/sbin/modemZapp\" \u003e /etc/paths.d/zmodemapp'\r\nOR use vi text editor as follows to create /etc/paths.d/zmodemapp file:\r\n$ sudo vi /etc/paths.d/zmodemapp\r\nAnd append the following text:\r\nhttps://www.cyberciti.biz/faq/appleosx-bash-unix-change-set-path-environment-variable/\r\nPage 3 of 4\n\n/usr/local/sbin/modemZapp\r\nSave and close the file. You need to reboot the system. Alternatively, you can close and reopen the Terminal app to\r\nsee new $PATH changes. For instance:\r\necho \"$PATH\"\r\nYou can show sorted path as follows:\r\necho \"${PATH//:/$'\\n'}\" | sort\r\nConclusion\r\nMacOS set or Change $PATH settings using any one of the following method as per your needs:\r\n1. Use the .bash_profile file when you need to generate the PATH variable for a single user account with\r\nBash.\r\n2. Use the /etc/paths.d/ directory or folder via the path_helper command tool to generate the PATH\r\nvariable for all user accounts on the system. This method only works on OS X Leopard and higher macOS\r\nversion.\r\nSee the following manual pages using the help command or man command on your macOS / OS X machine:\r\n$ man bash\r\n$ man path_helper\r\n$ help export\r\nSee also:\r\nCustomize the bash shell environments from the Linux shell scripting wiki.\r\n$PATH variable\r\nUNIX: Set Environment Variable\r\n🥺 Was this helpful? Please add a comment to show your appreciation or feedback.\r\nVivek Gite is an expert IT Consultant with over 25 years of experience, specializing in Linux and open source\r\nsolutions. He writes about Linux, macOS, Unix, IT, programming, infosec, and open source. Follow his work via\r\nRSS feed.\r\nSource: https://www.cyberciti.biz/faq/appleosx-bash-unix-change-set-path-environment-variable/\r\nhttps://www.cyberciti.biz/faq/appleosx-bash-unix-change-set-path-environment-variable/\r\nPage 4 of 4",
	"extraction_quality": 1,
	"language": "EN",
	"sources": [
		"MITRE"
	],
	"origins": [
		"web"
	],
	"references": [
		"https://www.cyberciti.biz/faq/appleosx-bash-unix-change-set-path-environment-variable/"
	],
	"report_names": [
		"appleosx-bash-unix-change-set-path-environment-variable"
	],
	"threat_actors": [],
	"ts_created_at": 1775434279,
	"ts_updated_at": 1775826705,
	"ts_creation_date": 0,
	"ts_modification_date": 0,
	"files": {
		"pdf": "https://archive.orkl.eu/4eb5c7d1a7592dfbbe51f39e8fa6778a25389526.pdf",
		"text": "https://archive.orkl.eu/4eb5c7d1a7592dfbbe51f39e8fa6778a25389526.txt",
		"img": "https://archive.orkl.eu/4eb5c7d1a7592dfbbe51f39e8fa6778a25389526.jpg"
	}
}