Difference between ls -l , ls -ltr and ll?

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?

  1. ll
  2. ls -l
  3. ls -ltr
1

1 Answer

First of all, the mentioned commands do not generate the same output. Here are the details:

  1. 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
  2. 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
  3. 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.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like