APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

Front Loading Commands


"I think I'm going crazy here!"

I recognized the voice at the other end of the phone line. "What's up?", I asked.

"I need to front-end ls, so I put my version in /specialstuff, but the stupid machine keeps using the ls in /bin. It's driving me nuts!"

Front-ending or front-loading is simply putting a special version of a command earlier in $PATH than a system command of the same name. Often the script or program calls the real system command with certain options or flags set to make it easier for users. Because the new version is earler in $PATH, it gets used rather than the system command.

"So you added /specialstuff at the front of $PATH ?". A rhetorical question, but I had to ask it.

"Duh, yes. What's really driving me crazy is that 'which ls' SAYS that ls is in /specialstuff, but when I type it, it doesn't use it. This machine hates me!"

I laughed. "Let me guess," I asked, "you changed $PATH and then put your ls into /specialstuff, right?"

"I don't know. Maybe. Why?"

"Because it matters. I also know that you typed ls after you changed $PATH but before you put your version in /specialstuff."

"Huh? How could you know that?

"Just trust me for a second. Type "hash -r" and then try your ls. Is it OK now?"

I heard keys clicking. "Son of a gun. Now it works. Why?"

Do you know why?

Answer



Got something to add? Send me email.





(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

-> -> Front Loading Commands



Increase ad revenue 50-250% with Ezoic


More Articles by

Find me on Google+

© Tony Lawrence



Kerio Samepage


Have you tried Searching this site?

Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us





The history of the world teaches us that succession is dangerous and that the strong take what they want. It's not likely to be any different with Linux. (Tony Lawrence)





This post tagged: