When i am using these commands , i am getting the same output but only order is getting changed for ls -ltr
command.
Can anyone please tell me what is the difference between the below commands?
ll
ls -l
ls -ltr
When i am using these commands , i am getting the same output but only order is getting changed for ls -ltr
command.
Can anyone please tell me what is the difference between the below commands?
ll
ls -l
ls -ltr
First of all, the mentioned commands do not generate the same output. Here are the details:
ll
: There is no command like ll
, in Ubuntu it is an alias for the command ls -alF
. you can find it by:
$ type ll
ll is aliased to `ls -alF'
-a
option is to show hidden files (will show .
and ..
too)
-l
option is to show the output as a long list along with various attributes e.g. permissions, file sizes, use, group, modification time etc.
-F
will append one of */=>@|
to the entries, it is basically used to differentiate files from directories as it will append /
to the directory entries
Example :
$ ll
total 24
drwxrwxr-x 4 chayan chayan 4096 Jun 25 13:53 ./
drwxrwxr-x 3 chayan chayan 4096 Jun 25 13:34 ../
drwxrwxr-x 2 chayan chayan 4096 Jun 25 13:35 data/
-rw-rw-r-- 1 chayan chayan 88 Jun 25 13:50 filenames.txt
ls -l
: As mentioned earlier -l
will show the entries as a long list along with various attributes.
Example:
$ ls -l
total 16
drwxrwxr-x 2 chayan chayan 4096 Jun 25 13:35 data
-rw-rw-r-- 1 chayan chayan 88 Jun 25 13:50 filenames.txt
ls -ltr
:
-t
option will sort the entries by modification date (with newest first)
-r
will reverse the sorting order.
As -t
will sort by modification time with newest first, -r
will cause the reverse i.e. oldest entries will be shown first now.
Example (Adding a file and a directory to make it clearer) :
$ ls -lt
total 16
drwxrwxr-x 2 chayan chayan 4096 Jun 25 13:50 log
-rw-rw-r-- 1 chayan chayan 88 Jun 25 13:50 filenames.txt
-rw-rw-r-- 1 chayan chayan 208 Jun 25 13:49 move.sh
drwxrwxr-x 2 chayan chayan 4096 Jun 25 13:35 data
$ ls -ltr
total 16
drwxrwxr-x 2 chayan chayan 4096 Jun 25 13:35 data
-rw-rw-r-- 1 chayan chayan 208 Jun 25 13:49 move.sh
-rw-rw-r-- 1 chayan chayan 88 Jun 25 13:50 filenames.txt
drwxrwxr-x 2 chayan chayan 4096 Jun 25 13:50 log
Check man ls
to get more idea.