Commands.page Logo

How to List File Permissions in Compressed Archive Ubuntu

This article provides a quick method for viewing file permissions stored within compressed archives on the Ubuntu operating system. It covers the necessary command-line instructions for common formats like tar and zip, allowing you to verify security attributes without extracting the contents. By following these steps, you can ensure file integrity and access rights before deployment.

Listing Permissions in Tar Archives

For .tar, .tar.gz, or .tgz files, use the tar command with the verbose flag. This lists the contents along with their permissions, owner, and group.

tar -tvf archive_name.tar.gz

The output begins with a permission string similar to drwxr-xr-x. The first character indicates the file type (dash for file, d for directory), followed by read, write, and execute permissions for the user, group, and others.

Listing Permissions in Zip Archives

For .zip files, the unzip utility or zipinfo command displays detailed information including permissions.

unzip -l archive_name.zip

Alternatively, use zipinfo for a more detailed view reminiscent of the ls -l output:

zipinfo -l archive_name.zip

Look for the permission column in the output to verify access rights. Note that zip files sometimes store Windows attributes instead of Unix permissions, so verify the source of the archive.

Verifying Specific Files

To check permissions for a single file within an archive without listing everything, combine the listing command with grep.

tar -tvf archive_name.tar.gz | grep specific_filename

This filters the output to show only the relevant file permissions, saving time when working with large archives.