Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Somehow the less command seems to have been removed from my system. I'm really not sure how it happened, but I need to get it back. My path seems to be fine, however the less file seems to be missing from my /usr/bin directory.

less: command not found

As this command is typically preinstalled, I can't find a way to reinstall it. I'm running on OSX 10.8.2.

Any idea where/how I can get this tool back?

Note that I'm talking about the basic less command (like the 'more' command), not the LESS CSS command.

share|improve this question
For the future, be careful about what you're doing when you have sudo rights. There'S no other way you could have removed a system binary. – slhck Jan 21 '13 at 8:04
up vote 0 down vote accepted

In fact, backup by TimeMachine is great idea!

Homebrew has a policy of not shipping formulae for commands that already exist on your system (e.g. less, perl, etc.). To get those, you will need to tap into another Homebrew repository:

brew tap homebrew/dupes

Now, you can run:

brew install less
share|improve this answer
First thing I tried; gives me: Error: No available formula for less – Nick Mitchinson Jan 21 '13 at 7:49
So try brew update before brew install less. – Paul Chechetin Jan 21 '13 at 7:51
I have; there is still not a formula for less. Have you been able to install less through brew before? – Nick Mitchinson Jan 21 '13 at 7:54
Homebrew itself doesn't bundle less since it's a duplicate of one of the built-in OS X tools, which Homebrew doesn't ship. cc @Nick – slhck Jan 21 '13 at 7:55
You guys are right. Try brew tap homebrew/dupes before install. I think I will work for you. – Paul Chechetin Jan 21 '13 at 7:59

You definitely want to try restoring it from a backup.

If that doesn't help, I've uploaded my less from 10.8.2 on my Dropbox for you to download.

Download it and run the following to make sure it's owned by the right user and has the correct permissions:

sudo cp ~/Downloads/less /usr/bin/less
sudo chown root:wheel /usr/bin/less
sudo chmod 755 /usr/bin/less

You might be able to use Pacifist to browse a DMG of a Mountain Lion installer image to search for the less binary as well.

share|improve this answer
The brew tap worked, but thanks so much for uploading the file just incase! – Nick Mitchinson Jan 21 '13 at 8:04
No problem. I'd suggest you download it and put it back into /usr/bin though. Homebrew installs less to a directory that OS X normally isn't aware of, so you could run into problems when less is trying to be used from shells that aren't aware of Homebrew at all. – slhck Jan 21 '13 at 8:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .