A friend of mine was looking for a file using Nautilus while logged in as root on a SLE server. He was looking for a particular file that started with a capital “S”, and simply could not seem to find it. He thought he was losing his mind, because he was certain it was there when logged in earlier (as his regular user).
Ah-hah! Some of you have already solved this riddle… but do you know the underlying reasons why this is the case? I’ll explain how it applies to bash on Suse, but it’s pretty much the same for other shells (and can be made to be the same on other distros).
You see, when you log in as regular user (meaning with a regular user profile) and do a file listing with Nautilus or
ls, you see the files listed in alphabetical order, regardless of case. When you are logged in as root, you see files listed in ASCII-like text order; meaning all uppercase letters completely precede the lowercase letters. It’s important to understand that these symptoms are not directly *caused* by Nautilus,
ls, or their options; in fact, these tools are simply responding to the order in which they see the files.
The magic is actually done by the “
LANG” (language) variable of the current user session. This is because for the root user, the
LANG value defaults to “
POSIX” (which honors the ASCII style listing), and for regular users it is set to “
en_US.UTF-8” (for English US, at least; obviously yours might be a different variant of
UTF-8), which is more human-style. Check it yourself with:
…which is set in
/etc/sysconfig/language. From that very file, I think the comment section explains it best:
# Local users will get RC_LANG as their default language, i.e. the
# environment variable $LANG . $LANG is the default of all $LC_*-variables,
# as long as $LC_ALL is not set, which overrides all $LC_-variables.
# Root uses this variable only if ROOT_USES_LANG is set to "yes".
So now it is all clear. You get to choose the order in which you want to see the files. But in the end, the standard behavior for the root user’s Nautilus or
ls listing results is probably the way most sysadmins prefer (for scripts, regex, and such), and the pretty alphabetical method is probably best for regular users (more like windows).
On a side note, as a bash user, you get a set of options for ls called
/etc/bash.bashrc. This file basically decides whether or not you are the root user, and if so, set the “
-A” option to show “Amost All” of the files (basically all except “.” and “..”). Just wanted to mention that in case you were wondering where all your so-called “hidden” files went, too…