Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So as pretty much everyone, before using Ubuntu I used a Windows machine, and one of the things I got used to in Windows was to use the underscore as the first character of a folder name as some sort of special marking so that it would be appear first on listing, both in command line and file explorer.

For instance, in my eBooks folder (in Windows) looks something like this:


but in Ubuntu's Nautilus it looks like this:


What is happening is that it is completely ignoring the underscore and it treats "_read" as "read" and therefore not listing it in first as wished.

I have tried setting the environment variable LC_COLLATE to C. This helps somehow since it lists the underscore together, but at the end, and not at the beginning.


share|improve this question
can you include a screenshot? – philshem Jan 10 '13 at 3:21
Possible duplicate of… although I think @maggotbrain's answer is better than the one presented there. – rudivonstaden Jan 14 '13 at 10:47

Since you have not specified the locale that you are currently using, this solution assumes that you are using en_US.UTF-8 as your default.

You can check this by running the command locale from the command line(Ctrl+Alt+t).

The variable that affects the sorting order of files is called LC_COLLATE.

According to the Ubuntu help pages, the LC_COLLATE variable determines "How strings (file names...) are alphabetically sorted. Using the "C" or "POSIX" locale here results in a strcmp()-like sort order, which may be preferable to language-specific locales."

The sort order will need to be changed from LC_COLLATE="en_US.UTF-8" to LC_COLLATE=C.

From the command line(Ctrl+Alt+t), enter:

update-locale LC_COLLATE=C

Note: You need to log out of your system and log back in order for the changes to take effect. Running the locale command, again, should show that the LC_COLLATE variable, along with the sorting order of ls -l, has been successfully changed.

share|improve this answer
should that not be update-locale LC_COLLATE=C? – rudivonstaden Jan 14 '13 at 8:50
also note that you need to log out for your locale changes to take effect. – rudivonstaden Jan 14 '13 at 10:23
I have already set the LC_COLLATE to C, as I have described in the last paragraph of my question. Still, I am getting different results in both the terminal and the nautilus explorer and I have rebooted the computer in the meanwhile. Any idea why that's happening? – nunos Jan 14 '13 at 14:37
@nunos Do you have any aliases set for ls in your .bashrc? – Kevin Bowen Jan 15 '13 at 1:02
update-locale LC_COLLATE=C does not help to get folders with underscores at the top of a sorted list if you use capital letters at the beginning of your folder names! – malisokan Jan 4 '14 at 19:34

Your Answer


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.