ls command

Posted on 2006-04-29
Last Modified: 2010-08-05
  it says  ls -c command list files by inode modification time. I know inode will be created only when file is created. So does this mean that this command would list the files in the order they are created ? What is the default order in which it would display the file the regular ls command ?

Question by:koppcha
    LVL 14

    Expert Comment

    The regular ls command lists the files in alphabetical order.

    I normally use ls -lat which gives the output in order of time.
    LVL 48

    Assisted Solution

    As the file creation time is not stored in Unix, there's no way you can easily tell for sure.

    inodes change if you chmod a file for example, so that would effect the sort order of 'ls -c'
    LVL 84

    Accepted Solution

        The time-related fields of struct stat are as follows:

         st_atime     Time when file data last accessed.  Changed by the mknod(2),
                      utimes(2) and read(2) system calls.

         st_mtime     Time when file data last modified.  Changed by the mknod(2),
                      utimes(2) and write(2) system calls.

         st_ctime     Time when file status was last changed (inode data modifica-
                      tion).  Changed by the chmod(2), chown(2), link(2),
                      mknod(2), rename(2), unlink(2), utimes(2) and write(2) sys-
                      tem calls.
    LVL 3

    Expert Comment

    Hi koppcha,

    There is one way to order the files by they last update date and time and you can do this with the following command: "ls -lrt" or you can use the following to do this by creation time: ls -lrc

    I hope it helps.
    LVL 48

    Expert Comment


    Please read previous comments explaining why Unix has no creation time.
    LVL 3

    Expert Comment

    So, koppcha can use: "ls -lrt" that lists from last update time. =0)

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. Please see for the updated article. It is avail…
    I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (…
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
    This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now