User:Andy Crowd/Get information about files

From ArchWiki
Jump to: navigation, search

Get information about files

For a new or unknown files

  • file - get a warrior information about a file
  • xdg-mime - getting a mime type of a file
  • md5sum - shows md5sum of a file
  • shasum - shows SHA sum, (sha1sum sha224sum sha256sum sha384sum sha512sum shasum)
  • ls, dir - those commands are used to list a content in folders

Mostly used on an already installed operative system

  • basename - shows only filename without its path. $ basename /path/filename will show only filename.
  • "${FilePathVariable##*/}" - same as basename but is a bash expression that cuts dir path
  • echo /path/filename | sed 's/[^*]*\///g' - shows the basename, same as two examples above
  • touch - can create an empty file but not overwriting if the file already exist and can change a file timestamps
  • stat - statistics of a file
  • lsof - list open files
  • mount - mount or show mounted files or devices
  • ps - shows information about processes
  • du - shows the size of a folder tree or a single file
  • if [ -f '/path/filename'];then echo exist;fi - checking if the file exists
  • if [ ! -f '/path/filename'];then echo exist;fi - checking if the file «doesn't» exists
  • getfacl - get info about file's extended access rights
  • getfattr - get info about extended attributes
  • find - search files or check for broken symlinks $ find -L -type l
  • find -type f -print0 | xargs -0 -L 1 file | grep text - grep from stdout info from file command.
  • df - shows up to ~95% of all available free as without reserved free space
  • tune2fs - shows a warriors information about block device including available reserved free space - tune2fs -l /dev/sd"XY"
  • pacman - arch package installer and can check which of packages a file belongs to. $ pacman -Qo /usr/bin/ifconfig
  • check dependences pactree -l pacman | sort -u | cut -f 1 -d ' '

Download files

With correct file names

  • wget - download files or mirror websites, to download with correct file names if possible:
wget --content-disposition -m -nd -nH http://website_to_mirror/
  • curl - download files
curl -J -O http://website_to_mirror/

See also in forum

dump links

From youtube:

lynx -dump '' |  awk '/http/{if(index($2,"watch"))print $2}'

See also: dump links


  • identify — Shows more information (and metadata) about image files.$ identify -verbose imagename || imagemagick
  • mediainfo — shows info about video/audio files.$ mediainfo -f mediafile || mediainfo
  • feh — Shows the image and/or information about it.$ feh -l imagename || feh
  • exiv2 — Shows a meta-data info of image files.$ exiv2 pr -v imagename || exiv2
  • pdfinfo — Shows extra information about PDF files.$ pdfinfo -js -meta -rawdates -box filename.pdf || poppler
  • jpeginfo — Shows info and integrity of jpeg files. $ jpeginfo -ci imagename.jpg. || jpeginfoAUR
  • pngcheck — Shows info and integrity of PNG, JNG and MNG image types. $ pngcheck *.png. || pngcheckAUR
  • exiftool — Shows metadata of images. $ exiftool *jpg. || not packaged? search in AUR
  • mogrify — Adding a comment to the image.$ mogrify -comment "yourcomment" /path/file.png. || imagemagick}}
  • which - Shows a path to an executable file by searching it in folders that are in the $PATH environment variable.$ which bash will show only /bin/bash.
  • isoinfo - Shows warriors information about the ISO image. isoinfo -d /path/isofile.iso

Check integrity of images with scripts

This is a python3 script that tests integrity of an image by loading its data and showing errors if got any. Requires the python-pillow library for the proper running. It can be combined with find -type f -name "*.jpg" -exec "{}" \; to check multiple images.

import sys
from PIL import Image
from optparse import OptionParser
parser = OptionParser()
(options, args) = parser.parse_args()
FileName = "".join(args)
    im =,"r")
except IOError:
    print("Cannot open the «",FileName,"» file!")
        TestLoadImgData = list(im.getdata())
     except IOError:
        print("An error was found in a «",FileName,"» file!")
        print("No Errors were found!")

Archive testers

  • p7zip — Test integrity of files in 7z, wim, tar archives. $ 7z t archivename * || p7zip
  • unrar — Test integrity of archive files. $ unrar t archivename * || unrar

Gzip and tar verbose test

$ gunzip -kvc archivename.tar.gz | tar tv
$ gunzip -ktv archivename.gz
$ tar tv archivename.tar
Note: Most of the compress/uncompress archive tools includes their own test abilities.

MIME-types list of the path to files

There are available additional preset MIME-type descriptions for a various desktop environments.

Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png

Reason: The following comparison table either conflicts with the previous note or the items should not be compared at all. defaults.list sets default applications associations, AFAIK the others don't. shared-mime-info is required by many desktop-independent packages. (Discuss in User talk:Andy Crowd/Get information about files#)
Package name Description Files
gnome-defaults-listAUR Ubuntu defaults /etc/gnome/defaults.list
mime-types Additional list of MIME-types /etc/mime.types
shared-mime-info XDG MIME-type database is a part of the package /usr/share/mime/packages/