file
What is file?
file
is a Linux tool that is used to read the magic bytes of a file. For example;
file example
we have the following 3 files
image.jpeg
information.txt
test.html
In this scenario we have an image file, a text file and a html file. The command file
seperates the files by the magic bytes of the file itself. Check the output below for a better understanding of the command "file"
How to use file
A file gets recognized by the extension that is in the naming of the file itself, and the magic bytes (signature).
What are magic bytes?
Magic bytes are often the very few first bytes of a file, and in some cases also the last few bytes of a file. Magic bytes are also called : file signature.
Lets say that we have 2 files, image.txt and information.txt. Apart from the naming before the extension, we cannot know for certain if a file is a text file, or an image file. This is the reason why magic bytes are brought up in the game. This is to know whether a file is indeed what the file tells you it is.
when looking up this link, there are a lot of different file signatures (file signatures = magic bytes). The magic bytes are set in hexadecimal, what represents a few special characters in the file itself.
For example :
JPEG image files will always start with the value :
PDF files will always start with the value :
references :
magic bytes explained
file signatures wikipedia
mime-type :
mozzila mime-types
Last updated
Was this helpful?