[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


ls command

Posted on 2006-04-29
Medium Priority
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

ID: 16570625
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

Tintin earned 80 total points
ID: 16570869
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 85

Accepted Solution

ozo earned 120 total points
ID: 16571273
    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.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

ID: 16650079
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

ID: 16653299

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

Expert Comment

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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…
Suggested Courses
Course of the Month20 days, 2 hours left to enroll

873 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