This is a list of commands that display information about a file: text, video, audio, image, etc.

Table of Contents

stat

stat <file>
$ stat image.png 
  File: image.png
  Size: 72536     	Blocks: 144        IO Block: 4096   regular file
Device: 8,5	Inode: 8010413     Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1000/ ricardo)   Gid: ( 1000/ ricardo)
Access: 2021-12-21 19:58:36.118356733 +0100
Modify: 2021-08-22 20:50:11.052218000 +0200
Change: 2021-09-10 17:19:53.046740133 +0200
Birth: 2021-09-10 17:19:53.030073466 +0200

file

file <file>
$ file image.png 
image.png: PNG image data, 256 x 256, 8-bit/color RGB, non-interlaced

soxi (from ‘sox’, for audio files)

soxi <audio file>
$ soxi audio.mp3 

Input File     : 'audio.mp3'
Channels       : 2
Sample Rate    : 48000
Precision      : 16-bit
Duration       : 00:03:22.82 = 9735552 samples ~ 15211.8 CDDA sectors
File Size      : 3.25M
Bit Rate       : 128k
Sample Encoding: MPEG audio (layer I, II or III)

ffmpeg (for video and audio files)

Useful if you have ffmpeg already installed and you don’t want to install another program.

ffmpeg -i <video or audio file>
$ ffmpeg -i video.webm
...
Input #0, matroska,webm, from 'video.webm':
  Metadata:
    ENCODER         : Lavf58.20.100
  Duration: 00:03:22.80, start: 0.000000, bitrate: 1570 kb/s
  Stream #0:0(eng): Video: vp8, yuv420p(progressive), 1920x1080, SAR 1:1 DAR 16:9, 29.97 fps, 29.97 tbr, 1k tbn, 1k tbc (default)
    Metadata:
      ENCODER         : Lavc58.35.100 libvpx
  Stream #0:1(eng): Audio: vorbis, 48000 Hz, stereo, fltp (default)
    Metadata:
      ENCODER         : Lavc58.35.100 libvorbis
...

mediainfo (for video and audio files)

mediainfo <video or audio file>
$ mediainfo video.webm 
General
Complete name                            : video.webm
Format                                   : WebM
Format version                           : Version 2
File size                                : 38.0 MiB
Duration                                 : 3 min 22 s
Overall bit rate mode                    : Variable
Overall bit rate                         : 1 570 kb/s
...

gm / identify (GraphicsMagick / ImageMagick, for image files)

GraphicsMagick is a great image editor, based on ImageMagick. You can use both programs to display image info.

# GraphicsMagick
gm identify <image file>
# ImageMagick
identify <image file>

There’s an optional -verbose argument for more info, including EXIF data (valid for ImageMagick and GraphicsMagick).

$ gm identify img01.jpg 
img01.jpg JPEG 3264x2448+0+0 DirectClass 8-bit 2.0Mi 0.000u 0m:0.000003s

pdfinfo (from ‘poppler’, for PDF files)

pdfinfo <PDF file>
$ pdfinfo preview.pdf 
Creator:         Adobe InDesign CC 2014 (Macintosh)
Producer:        GPL Ghostscript 9.55.0
CreationDate:    Tue Nov 30 18:43:49 2021 CET
ModDate:         Tue Nov 30 18:43:49 2021 CET
...
Pages:           5
Encrypted:       no
Page size:       419.528 x 595.276 pts
Page rot:        0
File size:       4144978 bytes
Optimized:       no
PDF version:     1.7

exiftool (from ‘perl-image-exiftool’ or ‘libimage-exiftool-perl’)

  • View metadata
    exiftool <file>
    
    $ exiftool test1.pdf 
    ExifTool Version Number         : 12.30
    File Name                       : test1.pdf
    ...
    Title                           : Untitled
    Creator                         : Draw
    
  • Edit metadata
    exiftool -<title>=<value> <file>
    
    $ exiftool -Title='My Report' test1.pdf
    
  • Remove all metadata
    exiftool -all= <file>
    
Test with this online terminal: