User:Andy Crowd/Get information about files
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 onlyfilename
. - "${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 existsif [ ! -f '/path/filename'];then echo exist;fi
- checking if the file «does not» 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 fromfile
command.
df
- shows up to ~95% of all available free as without reserved free spacetune2fs
- 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 'https://www.youtube.com/playlist?list=PL90ABNRn4Rq7n3xYPjRZZqRLYfoFrVDZj' | awk '/http/{if(index($2,"watch"))print $2}'
See also: dump links
Specialized
- identify — Shows more information (and metadata) about image files.
$ identify -verbose imagename
- mediainfo — shows info about video/audio files.
$ mediainfo -f mediafile
- feh — Shows the image and/or information about it.
$ feh -l imagename
- exiv2 — Shows a meta-data info of image files.
$ exiv2 pr -v imagename
- pdfinfo — Shows extra information about PDF files.
$ pdfinfo -js -meta -rawdates -box filename.pdf
- jpeginfo — Shows info and integrity of jpeg files.
$ jpeginfo -ci imagename.jpg
.
- pngcheck — Shows info and integrity of PNG, JNG and MNG image types.
$ pngcheck *.png
.
- exiftool — Shows metadata of images.
$ exiftool *jpg
.
- mogrify — Adding a comment to the image.
$ mogrify -comment "yourcomment" /path/file.png
.
- 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 ThisScript.py "{}" \;
to check multiple images.
#!/bin/python3 import sys from PIL import Image from optparse import OptionParser parser = OptionParser() (options, args) = parser.parse_args() FileName = "".join(args) try: im = Image.open(FileName,"r") except IOError: print("Cannot open the «",FileName,"» file!") else: try: TestLoadImgData = list(im.getdata()) except IOError: print("An error was found in a «",FileName,"» file!") im.close() else: print("No Errors were found!") im.close()")
Archive testers
- p7zip — Test integrity of files in 7z, wim, tar archives.
$ 7z t archivename *
- unrar — Test integrity of archive files.
$ unrar t archivename *
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.
Package name | Description | Files |
---|---|---|
gnome-defaults-listAUR | Ubuntu defaults | /etc/gnome/defaults.list /usr/share/applications/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/freedesktop.org.xml
|