LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices

Reply
 
Search this Thread
Old 01-18-2013, 04:15 AM   #1
lukerobinson
LQ Newbie
 
Registered: Aug 2012
Posts: 12

Rep: Reputation: Disabled
Output of ls -l


I'm probably being paranoid, but am slightly concerned about the order of files listed with ls -l.

Previously, I thought that on my system, files whose names began with upper case letters were all listed first, e.g.

luke@foo:~/test$ ls -l
total 0
-rw-r--r-- 1 luke luke 0 2013-01-17 17:26 C
-rw-r--r-- 1 luke luke 0 2013-01-17 17:26 a
-rw-r--r-- 1 luke luke 0 2013-01-17 17:26 b
-rw-r--r-- 1 luke luke 0 2013-01-17 17:26 d

Now though, those files are included among the files beginning with lower case characters, e.g.

luke@foo:~/test$ ls -l
total 0
-rw-r--r-- 1 luke luke 0 2013-01-17 17:26 a
-rw-r--r-- 1 luke luke 0 2013-01-17 17:26 b
-rw-r--r-- 1 luke luke 0 2013-01-17 17:26 C
-rw-r--r-- 1 luke luke 0 2013-01-17 17:26 d

Which is the correct order? Is there anything I've installed that might have changed that?

I am running Ubuntu 10.04.

Any help much appreciated.
Luke
 
Old 01-18-2013, 04:20 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
The order in which files are displayed depend on the LOCALE settings.

Have a look at this:
Code:
$ LC_ALL=en_US.utf8 ls -l
total 0
-rw-r----- 1 druuna druuna 0 Jan 18 11:18 A
-rw-r----- 1 druuna druuna 0 Jan 18 11:18 b
-rw-r----- 1 druuna druuna 0 Jan 18 11:18 C
-rw-r----- 1 druuna druuna 0 Jan 18 11:18 d
-rw-r----- 1 druuna druuna 0 Jan 18 11:18 E
-rw-r----- 1 druuna druuna 0 Jan 18 11:18 f

$ LC_ALL=POSIX ls -l
total 0
-rw-r----- 1 druuna druuna 0 Jan 18 11:18 A
-rw-r----- 1 druuna druuna 0 Jan 18 11:18 C
-rw-r----- 1 druuna druuna 0 Jan 18 11:18 E
-rw-r----- 1 druuna druuna 0 Jan 18 11:18 b
-rw-r----- 1 druuna druuna 0 Jan 18 11:18 d
-rw-r----- 1 druuna druuna 0 Jan 18 11:18 f
The locale settings can be checked with the locale command. This is what mine looks like:
Code:
$ locale
LANG=en_US.utf8
LANGUAGE=
LC_CTYPE="en_US.utf8"
LC_NUMERIC="en_US.utf8"
LC_TIME=nl_NL.utf8
LC_COLLATE=POSIX
LC_MONETARY="en_US.utf8"
LC_MESSAGES="en_US.utf8"
LC_PAPER=nl_NL.utf8
LC_NAME="en_US.utf8"
LC_ADDRESS="en_US.utf8"
LC_TELEPHONE="en_US.utf8"
LC_MEASUREMENT=nl_NL.utf8
LC_IDENTIFICATION="en_US.utf8"
LC_ALL=
The bold entry deals with sort order.

BTW: ls is not the only command influenced by the locale settings.

EDIT: Not sure if Ubuntu uses the same file but on Debian you can set preferences in /etc/default/locale

Last edited by druuna; 01-18-2013 at 04:23 AM.
 
Old 01-18-2013, 04:59 AM   #3
lukerobinson
LQ Newbie
 
Registered: Aug 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by druuna View Post
The order in which files are displayed depend on the LOCALE settings.
Many thanks. That would explain it.
 
Old 01-18-2013, 06:04 AM   #4
John VV
Guru
 
Registered: Aug 2005
Posts: 12,906

Rep: Reputation: 1715Reputation: 1715Reputation: 1715Reputation: 1715Reputation: 1715Reputation: 1715Reputation: 1715Reputation: 1715Reputation: 1715Reputation: 1715Reputation: 1715
This is a topic that comes up from time to time
most it is someone that notices what you did

most of the time the locale is set to "POSIX"
( not all of the time in all the world )

my understanding is it is the hexadecimal order of the name

BUT

some programs ( very few ) need to read files in a particular ORDER ( 1,2,3,4,5... aA,bB,cC,dD,...)
and this "odd" read order can cause some "fun"

one program in particular that this issue crops up in is the space sim "celestia"
most of the time from MS windows users adding parts to the program , but not all the time .
 
  


Reply

Tags
ls


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Requests to my ISP server are output in the middle of output by any command I run. stf92 Slackware 2 07-10-2012 08:38 AM
[SOLVED] Bash; awk or sed output to variable: how keep newline at end of each output line porphyry5 Programming 3 06-10-2011 05:50 PM
Standard script output to screen & -x option output to file BoBeau236 Programming 6 05-10-2011 07:43 AM
ps -eH | grep java output in a active passive clustered output johnkalikavunkal Linux - Server 2 01-30-2009 11:21 PM
the sound gives output when using mic but no output when run a music file medo Debian 0 04-19-2004 07:17 PM


All times are GMT -5. The time now is 11:22 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration