What is a computer file extension? | by Sam Writes Security | March 2022
The World Wide Web is a network rich in extensions. Today I am going to share with you what extensions are, where to apply them and how they work.
Without going too far into the technical side of things, I’ll let you know what extensions are so you know how to find them when they don’t seem apparent. A common file has a name and extension like cardgame.py or samsCV.pdf.
What types of files use extensions?
All computer programs and files use extensions, whether it’s a game, video, audio or image, all of these file types have extensions, and on Windows, operating system extensions are essential for easily running programs.
But, what are files anyway?
Three different types of files in computers?
Not all files are the same, so when you hear about a file, it might be the file type you know and sometimes it might not. So before making any decisions on the subject make sure you know which of these three is the folder in question “aapplication files, data filesand system files”.
Text editors and extensions
Usually, when we finish writing a document using Libre Office or Microsoft Word, we name these documents ourselves, because otherwise the program will name it randomly, like document 1 for example and nobody likes that.
Also, having multiple files with random names won’t help us remember what the documents are for and what they’re talking about, ideally we erase everything before the .docx for Microsoft word or .odt for Libre Office, do you know why?
the .docx on Microsoft Word files is the extension generated by the Word editor, .docx is a document extension. And no, you’re not crazy. Word file extensions did not have an X before the introduction of Word 2007, it was . DOC but now these documents are based on the XML format, hence the “X”.
XML stands for The Extensible Markup Language, which is made up of both markup and text and is derived from SGML
Microsoft Word is very popular, used for both personal and professional purposes, which means that most text editors and document readers are compatible with Microsoft Word files. What I mean here is that I can start writing in Word and easily finish it in Libre Office or Google Docs.
Q: What happens if I delete while trying to rename a document including the file extension (Windows OS)?
Before I answer that, here’s another question;
Q: What happens when we double click on a pdf file on our computer, what program opens the file if we have not set any as the default document viewer, given that our browsers allow us today open and read pdf files?
Let’s define what file extensions are so that we can easily answer this mystery.
What are computer file extensions?
In short, we can define a computer file extension as a suffix at the end of a computer file program. This extension is usually made up of two to four digits. Very common daily extensions that most of us deal with are; Docx Pdf. Exe.Xml. jpg. png. mp3 .mp4 and maybe .avi?
Python file extensions have two digits. (PY) and HTML files have four digits (HTML).
A: When we save a file without an extension in Windows the system does not open the file because it does not know what program is associated with this type of file. This is an important role of extensions under Windows.
Thanks to a file extension, our operating systems know which program to use to display or execute commands and without an extension it is not possible.
A: Unless a program is configured to open .pdf files, no program will open the document by default.
We are usually asked to choose one program from various available on our computer that can do the job.
In Windows, the system knows what to do with a file thanks to the file extension and that’s why in our first example I mentioned that unless otherwise specified, your system will not know what to do with a file or a document.
macOS and Linux use file extensions differently than Windows
By default, macOS does not show file extensions, but this can be easily set via Finder > Preferences > Advance and enable “Show all filename extensions”.
Depending on your Linux distro, if this doesn’t come by default, you can configure it to show file extensions as well.
Unlike Windows, and instead of file extensions, Mac and Linux rely on MIME types and creator codes located on the file header to determine how to run files and with which program to do the job. So, with and without an extension, you can still run programs on Linux and macOS.
What happens when we change file extensions?
On Windows, you get a warning, and once this is done, the system tries to open the file using the new extension, resulting in an error.
On Mac, you cannot do this using the Finder. The Finder will remove it but the system will put that extension back a few seconds later and you have MIME type data to thank for that.
Linux is tricky depending on your distro, it actually lets you modify the extension to your liking. But, once it is done, if it is not the proper extension, it fails to load the file.
This error came from a document in .odt format that I renamed and changed its extension to .pdf and I received this error message. I renamed it a second time and deleted the old and new extension. Guess what happened? I opened it using Libre-Office with no extension in place. MAGIC!!!!!
Why should you know about common extension file types (from a security perspective)?
Knowing this will mainly help you understand your files better, determine what goes where, and where to make some changes if needed. But above all, it could prevent you from falling into traps.
I assume you are aware of phishing attempts and how to avoid them. I wrote about it many times before you could see How to become a victim of cyberattacks, How to fight cybercrime, A letter from Mrs. Hannah, Keep your data away from suspicious emails and We are all vulnerable because we are human. That’s more than enough self-promo for the day, please let us carry on →…
Knowing what a Windows executable file extension looks like, you wouldn’t dare to click on a file from untrusted sources because you know better.
PDFs can contain documents, but no one saves all of their photos as PDFs, so don’t click on them. You can include some executable file information, but no resume should be in the form of an .exe file. I’m sure you get the idea.
The different way in which Mac and Linux read and execute files does not change the fact that these files must be compatible, which is why programs are made available for these different platforms, with or without an extension. if it was not designed for Mac, it will not work on Mac.
For this last example I will use a very popular program available for all major platforms, VLC, a media player and an open source program.
We’re not doing anything special here, just clearing things up. Not having an extension does not create superpowers for the operating system. If the program is not designed for the correct operating system, it simply will not work.
Thanks to the power of our browsers and cookies and the servers behind these sites, when you visit a website like Videolan because it has already recognized your operating system, it provides you with the appropriate version, but you can always change it using the drop down option I selected on the screenshot above.
Use this information about extensions and document types to choose the correct version of any program or document for your device.
Drop your questions in the comments, let me know if it was helpful and as always BE CAREFUL.