How do I display timestamps using the ls command in Linux?

Published on Aug. 22, 2023, 12:17 p.m.

To display timestamps of files using the ls command in Linux, you can use the -l option along with the command. The -l option provides a detailed listing of the file or directory, including the timestamp information. The timestamp information includes the file’s modification time, which is indicated by the letter “M” in the month field. Here is an example command:

ls -l file.txt

This will display the detailed information of the file.txt file, including its timestamp information. The timestamp information is listed in the sixth column of the output. If you want to display the timestamp information in a different format, you can use the --time-style option to specify the format. For example, to display the timestamp information in ISO format, you can use the following command:

ls -l --time-style=iso file.txt

This will display the timestamp information of the file.txt file in ISO format. Alternatively, you can use the stat command to display more detailed timestamp information, including the file’s access, modification and change timestamps. Here is an example command:

stat file.txt

This will display the timestamp information of the file.txt file, including its access, modification and change timestamps.

Tags:

ls