On a fresh WordPress install in Linux distributions, wp-config-sample.php contains Carriage Return control characters that are not found in any other .php file in the distribution.


egrep -l $'\r'\$ *.php

in WP's base dir, will return only wp-config-sample.php

I am not worried about eliminating the control character, nor am I worried that it interferes with install operations (it doesn’t).

I’d just like to find out if there’s a reason why wp-config-sample.php is the only file with this anomaly.

WP versions
Issue was reported in version 4.6.15. It is still present in the latest version 5.5

This behavior has been seen in

  • Debian 10 CLI-only
  • Ubuntu 18.04.4 LTS
  • Ubuntu 12.04.5 LTS
  • Ubuntu 20.04.1 LTS

WordPress distributions
Install files have been downloaded either

  • as .zip file (e.g. wordpress-5.5.zip) or
  • as .tar.gz file (e.g. wordpress-5.5.tar.gz)

Downloads methods

  • via wget: wget https://wordpress.org/latest.zip
  • via WP CLI: wp core download
  • via a Web browser (in GUI environments)

Example screenshot from Ubuntu 12.04.5 LTS

Ubuntu 12.04.5 tar.gz version

A Google search doesn't provide any explanation. I have found only a similar question in the WP support forum but the reply given is "don't worry about it" and does not provide an explanation for it.

  • Would be good feedback to explain why this has been downvoted.
    – Dave White
    Aug 13, 2020 at 14:59
  • 1
    I just now downloaded clean copies of the latest WordPress release (5.5) in both .zip and .tar.gz flavours from here—wordpress.org/download—and, upon decompressing them, I don't see ^M characters in wp-config-sample.php or in any of the other PHP files I randomly checked (index.php, wp-includes/class-wp-oembed.php). How are you downloading WordPress to your Linux environment?
    – Pat J
    Aug 14, 2020 at 20:36
  • @PatJ either via wget or via WP CLI. Have you opened wp-config-sample.php with vi from a command line?
    – Dave White
    Aug 14, 2020 at 20:37
  • 1
    Yes, all my command-line editing is done with vi. (Well, I suppose it's vim, if we're getting technical -- specifically VIM - Vi IMproved 8.1 (2018 May 18, compiled Apr 15 2020 06:40:31).)
    – Pat J
    Aug 14, 2020 at 21:07
  • @PatJ not sure why you are not experiencing this - I have revamped the question with 3 Linux versions and all the methods used, I still see the issue regardless.
    – Dave White
    Aug 15, 2020 at 10:37

2 Answers 2


Unix and Unix-like operating systems (like Linux) use different line endings in their text files.

The format of Windows and Unix text files differs slightly. In Windows, lines end with both the line feed and carriage return ASCII characters, but Unix uses only a line feed. As a consequence, some Windows applications will not show the line breaks in Unix-format files. Likewise, Unix programs may display the carriage returns in Windows text files with Ctrl-m (^M) characters at the end of each line.

—From Convert between Unix and Windows text files

Presumably you've copied a file that was created on Windows to a Linux machine, and so you're seeing the Windows line endings when you edit the file on Linux.

The solution provided in your wordpress.org support post -- use dos2unix -- will clean it up.

I can't say precisely why your question was downvoted, as I'm not the downvoter, but if I had to guess I'd say it was because this is a Windows / Linux question, not a specifically WordPress-related question. (Yes, it's a WordPress file, but it's not really related to WordPress development at all.)

  • 1
    Thx Pat, I have upvoted your answer because I think it made me realize I probably did not write it clearly enough - respectfully, I don't believe it answers my question. I am aware of what you say about the differences between how a Windows environvment Vs. a Unix/Linux environment handles text files. My question is: why is wp-config-sample.php the only .php file in the Wordpress displaying this behaviour? Also, I think this is specific to WordPress because there is only this one file which appears to differ from the rest. I hope it makes sense. I will edit my question for clarity now.
    – Dave White
    Aug 14, 2020 at 20:21

From Wordpress support:

It’s for formatting on legacy DOS based systems. Some DOS and Windows based editors will not handle the file correctly without those additional ^M carriage return character. A UNIX based system will work with or without them and that’s why they don’t matter.


This is how a portion of that file should edit.

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'database_name_here' );
/** MySQL database username */
define( 'DB_USER', 'username_here' );
/** MySQL database password */
define( 'DB_PASSWORD', 'password_here' );
/** MySQL hostname */
define( 'DB_HOST', 'localhost' );

Which is readable.

If a new user used the Windows notepad editor then the file would may look like this especially on older versions of Windows.

// ** MySQL settings - You can get this info from your web host ** ///** The name of the database for WordPress */define( 'DB_NAME', 'database_name_here' );/** MySQL database username */define( 'DB_USER', 'username_here' );/** MySQL database password */define( 'DB_PASSWORD', 'password_here' );/** MySQL hostname */define( 'DB_HOST', 'localhost' );

Which is one line of mess. It would still work as a PHP file because the newline is less important than the ; in the file. The additional ^Ms will be ignored and for those other editor applications the user will see something they can both parse and edit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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