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

Front Loading Commands

Some material is very old and may be incorrect today

© July 2005 Tony Lawrence

"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?


If you found something useful today, please consider a small donation.

Got something to add? Send me email.

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

Printer Friendly Version

-> Front Loading Commands

Inexpensive and informative Apple related e-books:

Photos for Mac: A Take Control Crash Course

Take Control of the Mac Command Line with Terminal, Second Edition

Take Control of Upgrading to El Capitan

iOS 8: A Take Control Crash Course

Take Control of Automating Your Mac

More Articles by © Tony Lawrence

Printer Friendly Version

Have you tried Searching this site?

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

Printer Friendly Version

Beware of bugs in the above code; I have only proved it correct, not tried it. (Donald Knuth)

Linux posts

Troubleshooting posts

This post tagged:


Unix/Linux Consultants

Skills Tests

Unix/Linux Book Reviews

My Unix/Linux Troubleshooting Book

This site runs on Linode