Jollyra
Jollyra

Reputation: 703

Large PATH variables

Could having a very large PATH variable noticeably slow down your computer? If so, would it only slow down the computer when using terminal or would it slow down the machine in general?

Practically speaking, is it beneficial to keep a small PATH variable?

Upvotes: 0

Views: 226

Answers (1)

twalberg
twalberg

Reputation: 62389

It should not noticeably slow down your computer as a whole. Most shells do at least some limited caching (last time we ran ls, we found it in /usr/bin), on top of the fact that your system will generally have a significant amount of file system metadata cached. If you type a command that you haven't run before, and it happens to be in the 200th directory in your PATH, or if your system is under significant virtual memory pressure (in which case it's just going to be slow anyway), you will probably notice some delay in launching the command, but the second time you run it it should be less noticeable. This will be considerably worse if some of your PATH elements are on network file systems, slow devices like CD/DVD media, etc., or if you are on an ancient system that is either just plain slow by todays standards or has very small memory. I would recommend at least periodically reviewing your PATH to see if there are directories that no longer exist or are no longer used which you can prune out, but in general a longer PATH is not overly problematic.

If you find that it is a problem, you can create a small directory that contains symbolic links to the binaries you need from other paths and/or small wrapper scripts to launch the appropriate applications, and only include this directory in your path (in addition to the system standard locations) rather than every individual directory that one or two binaries live in...

Upvotes: 1

Related Questions