Commands.page Logo

How to View Last Modified Date in Tar Archive Ubuntu

This guide explains how to inspect the metadata of files stored within a tar archive on Ubuntu. You will learn specific command-line options to list file details, including permissions, ownership, and specifically the last modified date, without needing to extract the archive contents first.

Use the Tar List Command

To view the contents of a tar archive along with their modification dates, open your terminal. You will use the tar command with the verbose list option. This displays detailed information about every file stored inside the compressed or uncompressed archive.

Run the following command, replacing archive.tar with the name of your file:

tar -tvf archive.tar

If your archive is compressed, such as a .tar.gz or .tar.bz2 file, the command remains the same because modern versions of tar detect the compression automatically:

tar -tvf archive.tar.gz

Understanding the Output

The command outputs a list where each line represents a file. The columns display permissions, owner, group, size, date, time, and filename. The last modified date appears immediately before the time and filename.

An example output line looks like this:

-rw-r--r-- user/group      1024 2023-10-25 14:30 filename.txt

In this example, 2023-10-25 14:30 indicates the last modified timestamp. You can scan this list to verify when specific files were last changed before they were archived.