19

I am using Trisquel 7.0 with Nautilus 3.10.1 installed.

Whenever I display properties of a file, I've one file-specific tab like: Image,Audio/Video,Document etc. which displays special information about it.

Example for a Image:

screenshot

Example for a PDF Document:

screen-shot

How does Nautilus get this type of file-specific information?

And how do I print this information (MetaData) with te command-line?

2 Answers 2

24

For the first level of information in the command line, you can use file.

$ file gtu.pdf 
gtu.pdf: PDF document, version 1.4

For most formats, and more detailed information, you can also use Exiftool:

NAME
       exiftool - Read and write meta information in files

SYNOPSIS
       exiftool [OPTIONS] [-TAG...] [--TAG...] FILE...
       exiftool [OPTIONS] -TAG[+-<]=[VALUE]... FILE...
       exiftool [OPTIONS] -tagsFromFile SRCFILE [-SRCTAG[>DSTTAG]...] FILE...
       exiftool [ -ver | -list[w|f|r|wf|g[NUM]|d|x] ]

       For specific examples, see the EXAMPLES sections below.

       This documentation is displayed if exiftool is run without an input FILE when one is expected.

DESCRIPTION
       A command-line interface to Image::ExifTool, used for reading and writing meta information in a variety of
       file types.  FILE is one or more source file names, directory names, or "-" for the standard input.
       Information is read from source files and printed in readable form to the console (or written to output text
       files with -w).

Example:

$ exiftool IMG_20151104_102543.jpg 
ExifTool Version Number         : 9.46
File Name                       : IMG_20151104_102543.jpg
Directory                       : .
File Size                       : 2.8 MB
File Modification Date/Time     : 2015:11:04 10:25:44+05:30
File Access Date/Time           : 2015:11:17 18:56:49+05:30
File Inode Change Date/Time     : 2015:11:11 14:55:43+05:30
File Permissions                : rwxrwxrwx
File Type                       : JPEG
MIME Type                       : image/jpeg
Exif Byte Order                 : Big-endian (Motorola, MM)
GPS Img Direction               : 0
GPS Date Stamp                  : 2015:11:04
GPS Img Direction Ref           : Magnetic North
GPS Time Stamp                  : 04:55:43
Camera Model Name               : Micromax A121
Aperture Value                  : 2.1
Interoperability Index          : R98 - DCF basic file (sRGB)
Interoperability Version        : 0100
Create Date                     : 2002:12:08 12:00:00
Shutter Speed Value             : 1/808
Color Space                     : sRGB
Date/Time Original              : 2015:11:04 10:25:44
Flashpix Version                : 0100
Exif Image Height               : 2400
Exif Version                    : 0220
Exif Image Width                : 3200
Focal Length                    : 3.5 mm
Flash                           : Auto, Did not fire
Exposure Time                   : 1/809
ISO                             : 100
Components Configuration        : Y, Cb, Cr, -
Y Cb Cr Positioning             : Centered
Y Resolution                    : 72
Resolution Unit                 : inches
X Resolution                    : 72
Make                            : Micromax
Compression                     : JPEG (old-style)
Thumbnail Offset                : 640
Thumbnail Length                : 12029
Image Width                     : 3200
Image Height                    : 2400
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Aperture                        : 2.1
GPS Date/Time                   : 2015:11:04 04:55:43Z
Image Size                      : 3200x2400
Shutter Speed                   : 1/809
Thumbnail Image                 : (Binary data 12029 bytes, use -b option to extract)
Focal Length                    : 3.5 mm
Light Value                     : 11.9

There are also specific commands for some type of files, like pdf:

$ pdfinfo gtu.pdf 
Title:          Microsoft Word - Thermax Ltd
Author:         User
Creator:        PScript5.dll Version 5.2.2
Producer:       GPL Ghostscript 8.15
CreationDate:   Tue Jan 27 11:51:38 2015
ModDate:        Tue Jan 27 12:30:40 2015
Tagged:         no
Form:           none
Pages:          1
Encrypted:      no
Page size:      612 x 792 pts (letter)
Page rot:       0
File size:      64209 bytes
Optimized:      yes
PDF version:    1.4
0
5

The actual meaning of generic "file metadata" would involve whatever information is not stored inside the file itself which is the data. It's data about the data.

Under such a meaning, metadata include (but are not limited to):

  • Access rights
  • Size in bytes and in blocks
  • SELinux security context string
  • User and Group ID of the owner
  • Time of last modification

This type of information is normally stored into the filesystem and not into the file itself.

Now, as far as Linux (and Unix-like) CLI is concerned, there is a small nifty tool called stat which can provide all available metadata for a file, a file system or any other file system-related item (like directories, devices and named pipes).

It uses a printf-like notation to define the actual information to be printed out, or a default selection when such an option is not used.

This is an example run:

[enzo@Feynman ~] stat /etc/hosts 
  File: /etc/hosts
  Size: 139             Blocks: 8          IO Block: 4096   regular file
Device: 10303h/66307d   Inode: 268684872   Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2021-09-14 18:00:17.200000397 +0200
Modify: 2021-09-14 17:59:37.506668910 +0200
Change: 2021-09-14 17:59:37.520002245 +0200
 Birth: 2021-09-14 17:59:37.506668910 +0200

The earlier answer shows a mix of file metadata and data extracted with a specific tool for each file type, so it is not strictly about metadata.

On the other hand, stat is more generic and works on any file object and doesn't access the file data itself.

For extra details about the actual content type, thus not really metadata in the strict sense, you can make use of the ubiquitous file tool which uses a large "signature" database (the magic numbers database) to guess the file content, no matter what its name can be: it doesn't use the so-called file name extension.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .