Getting dos2unix and unix2dos On Ubuntu

Since – unlike most other Linux distros – Ubuntu doesn’t come standard with either dos2unix or unix2dos, you have to install it yourself.  The package “tofrodos” in the repos is what you’ll want, and the simplest method to install it is, of course:

sudo apt-get install tofrodos

However, unless you want to retrain yourself to use their naming conventions (which I certainly don’t), you’ll want to add one final piece to the process:

vi ~/.bashrc

In there, add two new aliases:

alias dos2unix=’fromdos’;
alias unix2dos=’todos’;

Save and exit, and then simply type the following to update your session:

. ~/.bashrc

DO NOT, however, do that with your .bash_history file, as Philip Olson did a couple of years ago.  ;-P


Leave a Reply

Your email address will not be published. Required fields are marked *