Where's dos2unix? In Ubuntu's tofrodos package!

I had a strange error recently to do with a bash script not running correctly. I couldn't see anything wrong with the file until I noticed that VIM was reporting that the file's type was DOS.

What I needed was to convert the downloaded file to UNIX file format using dos2unix but which package does it live in? A quick search of the Ubuntu packages database revealed tofrodos:

Converts DOS <-> Unix text files, alias tofromdos

DOS text files traditionally have CR/LF (carriage return/line feed) pairs as their new line delimiters while Unix text files traditionally have LFs (line feeds) to terminate each line.

Tofrodos comprises one program, "fromdos" alias "todos", which converts text files to and from these formats. Use "fromdos" to convert DOS text files to the Unix format, and "todos" to convert Unix text files to the DOS format.

This functionality is also available via the dos2unix/unix2dos symlinks.
To install it run:
sudo aptitude install tofrodos
And then use dos2unix and unix2dos to convert the file between the two different formats.

Technorati Tags: , , ,


jusuchin85 said...


Been looking for this for my assignments. Now that I found it, I can conveniently do the conversion at home.

Thanks again!

abeacock said...

Happy to help jusuchin85!

ricgal said...

Is that a command line tool I would use in Konsole

ricgal said...

Just to check, is this a command line utility to use in Konsole?

I know, silly question, but I deal with so many basic tech support questions every day that I always need the silly specifics :)

ricgal said...

sorry for the double post. Somehow after I logged in I didn't realize that it had not lost my original post

abeacock said...

ricgal, yes it's a command line program. And no it's not a silly question! :)

WotsInAName said...

A quick search for "dos2unix for ubuntu" took me to ur page. Thanks buddy!!

abeacock said...

WotsInAName, glad you found me!

Udit said...

Thanks man. Found you from Google.

Darren said...

True to the title of this blog post, where the *&*@&!@& is dos2unix? It's NOT in tofrodos!

On an Ubuntu 10.04 system:

$ sudo apt-get install tofrodos
$ dos2unix
dos2unix: command not found
$ unix2dos
unix2dos: command not found
$ apt-file list tofrodos
tofrodos: /usr/bin/fromdos
tofrodos: /usr/bin/todos
tofrodos: /usr/share/doc/tofrodos/NEWS.Debian.gz
tofrodos: /usr/share/doc/tofrodos/changelog.Debian.gz
tofrodos: /usr/share/doc/tofrodos/copyright
tofrodos: /usr/share/doc/tofrodos/readme.txt.gz
tofrodos: /usr/share/doc/tofrodos/tofrodos.html
tofrodos: /usr/share/man/man1/fromdos.1.gz
tofrodos: /usr/share/man/man1/todos.1.gz

Yea, so there is no 'dos2unix' or 'unix2dos' symlinks in this package. It's a pain, because this command has been around for decades, by those names. Who's bright idea was it to change the names and/or to remove the symlinks?

Andy B said...

Darren, thank you so much for posting that as I think it just points out the craziness that is ubuntu as far as failing to keep consistent things consistent!

I can't believe they have renamed the files and not even supplied some symlinks!

Juan Manati said...

Use $ fromdos instead of $ dos2unix
$ todos instead of $ unix2dos

Anonymous said...

sudo ln -s /usr/bin/fromdos /usr/bin/unix2dos

sudo ln -s /usr/bin/todos /usr/bin/dos2unix

Anonymous said...

I think those simlinks are backwards. I used:

sudo ln -s /usr/bin/fromdos /usr/bin/dos2unix

sudo ln -s /usr/bin/todos /usr/bin/unix2dos