When ls displays the contents of a directory, the file is displayed in alphabetical order from a to z. The priority is as follows;
Number
A-z
A-Z
That is to say, if you do not add any sort parameters, the first letter of the file name is a number, will give priority to display; second is the A-Z, then is a-z; below is a few sort parameters, you will know after a few exercises;
The-S parameter is used for sorting the file size;
For reverse sorting, we need to use the-r parameter;
The-t parameter is used for sorting by the last access;
Sort by extension. The-X parameter is used;
Example
[root@localhost ~]# ls
123.txt fonts.scale kernel myinstall.log upgrade.log
anaconda-ks.cfg install.log.syslog mkuml-2004.07.17-ananas.tar.bz2 plinux.txt upgrade.log.syslog
[Root @ localhost ~] # Ls-lS/root
[Root @ localhost ~] # Ls-lS
Total 180
-Rw-r -- 1 root 68012 04-04 mkuml-2004.07.17-ananas.tar.bz2
-Rw-r -- 1 root 53992 03-16 08:54 myinstall. log
Example:
[Root @ localhost ~] # Ls-lr
Total 180
-Rw-r -- 1 root 0 03-26 18:39 upgrade. log. syslog
-Rw-r -- 1 root 613 03-26 18:41 upgrade. log
-Rw-r -- 1 root 0 04-19 14:10 plinux.txt
[Root @ localhost ~] # Ls-lt
Total 180
Drwxr-xr-x 2 root 4096 04-19 20:04 kernel
-Rw-r -- 1 root 21 04-19 :06 123.txt
-Rw ------- 1 root 1375 04-19 anaconda-ks.cfg
-Rw-r -- 1 root 0 04-19 14:10 plinux.txt