$uname -a

Linux vm-** 2.6.32-573.8.1.el6.x86_64 #1 SMP Fri Sep 25 19:24:22 EDT 2015 x86_64 x86_64 x86_64 GNU/Linux

I downloaded dos2unix-7.3.3-win32.zip and unzipped it. Under bin folder from the unzipped file, I got dos2unix.exe

How to install dos2unix in Linux?

I can't do yum install dos2unix as I am not & can't get root access.

5 Answers 5


Other answers show how to download and compile dos2unix, but if you're simply looking to convert files from DOS-style line endings (CR-LF) to Unix-style line endings, there are several other approaches which shouldn't involve installing anything:

  • if you have tr:

    tr -d '\r' < input > output
  • if you have Perl:

    perl -pi -e 's/\r\n/\n/g' input

    (which converts the file in-place, same as dos2unix)

  • if you have sed:

    sed -i 's/^M$//' input

    where you'd press CtrlV then CtrlM to get ^M.

  • +1. I have many files in my directory. I am executing find . -type f -exec dos2unix {} \; In your example for tr and sed, how can I achieve for many files? Apr 18, 2016 at 10:13
  • I wouldn't use the tr version in that case, but with sed, find . -type f -exec sed -i 's/^M$//' {} \; should work. Better still, find . -type f -print 0 | xargs -0 sed -i 's/^M$//', which will process as many files as possible each time it runs sed. Apr 18, 2016 at 10:18
  • And if you don't need to process files in subdirectories, sed -i 's/^M$//' * would work just as well. Apr 18, 2016 at 10:19
  • In my input file I have 2 records. Both the records contain ^M character. When i run sed -i 's/^M$//' input > output , my output file is containing 0 records. I think sed is removing the record which contains ^M. Instead I want the record to be retained, but only remove ^M. Apr 18, 2016 at 11:00
  • I just found out sed -i 's/\r//' * works. Let me know if there is a better way. Apr 18, 2016 at 11:06

First of all, you downloaded a dos2unix executable for windows (dos2unix-7.3.3-win32.zip), which is not what you want because you are using Linux.

Try downloading the source code for dos2unix for Linux and extract it to your home dir:

mkdir $HOME/bin/
tar -zxvf dos2unix-7.3.3-src.tar.gz # the exact name of the downloaded file may vary
cd dos2unix-7.3.3
./configure --prefix=$HOME/bin/
make install

if everything goes well you will be able to find a dos2unix file somewhere in your $HOME/bin directory. you can use this new installation by typing

$ ~/bin/dos2unix windows_formatted_file.txt
  • how to install make w/o sudo... :)
    – viru
    Feb 17 at 4:58

You have to download the source code and compile it.

Here is the source code.

To untar it execute: (VERSION equals to the version you have downloaded)

tar xvf dos2unix-VERSION.tar.gz

Finaly execute:


If the compilation succeeded, it will appear an executable called dos2unix and unix2dos.


Download dos2unix-7.3.3.tar.gz.

tar xvzf dos2unix-7.3.3.tar.gz
cd dos2unix-7.3.3
make install prefix=$HOME

This will install dos2unix in $HOME/bin/.

For further information see INSTALL.txt.


You need to download the specific RPM from the OS website. For example, for CentOS, download the RPM file from http://vault.centos.org/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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