Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I accidentally overwrote one of the programs in the /bin directory, and would like to fix it. I am using Ubuntu 11.10, and would like some way to re-install just this file, without having to re-install the whole distribution.

Specifically, I accidently typed in the following command:

ls > less

I meant to pipe the output of of ls into the less program for easy viewing, which should have been:

ls | less

The command worked because I was (shame on me) logged in as a super user. I opened up the less file in the /bin directory, and sure enough it is now a text file with the output of my ls command. Is there anyway to fix this? It is especially annoying because I can't view the manual pages for any commands. Thanks for your help, I am just learning Linux.

share|improve this question

migrated from stackoverflow.com Feb 4 '12 at 2:31

This question came from our site for professional and enthusiast programmers.

    
what linux distribution are you on? –  Ben Feb 4 '12 at 2:23
8  
if ubuntu, you would do: sudo apt-get install --reinstall less –  clime Feb 4 '12 at 2:27
    
Especially if you're just learning Linux, don't do it while logged in as a super user. Bad things (like this) will be bound to happen. ;) Running as root is generally discouraged for all but only the specific cases where it's absolutely necessary. –  Ben Richards Feb 4 '12 at 4:02
    
Thanks clime, I ran your command and it worked perfectly! I can once again read the manual pages! –  jdg Feb 4 '12 at 4:39
5  
@clime - You should make your comment an answer. –  Nifle Feb 4 '12 at 8:34
add comment

2 Answers

the following works on Debian and grudgingly Ubuntu:

sudo apt-get install --reinstall $(dpkg -S /usr/bin/less | cut -d: -f 1)
share|improve this answer
add comment

A more fundamental solution to this problem would be to make backups of your system to another drive using something like rsync. That way you can restore any file that has problems. You'll need to do this to protect your data files anyway.

There is a bewildering array of backup systems available for Linux, but just a simple rsync will do what you want. If possible, one copy of everything should be on an external drive - preferably stored at a remote location so it will not be physically vulnerable to problems where your computer is located.

While on the subject, check out most. It does what less does and includes horizontal scrolling as well as many other features.

http://linux.die.net/man/1/most

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.