File Names and Extensions
Every file stored on a computer is given a file name that allows the computer user to easily figure out what data it contains. Most are also given a file extension. File extensions allow the computer’s operations system to know what application software should be used to open the file, since not all applications can open all file types. The extensions can also help the user remember the type of data stored in the file.
Extensions are typically added by the computer when the file is created, but they can also be typed as part of the file name by the user. The computer will allow you to type an extension into the file name whether or not it matches the file type; for example, a file named funny.jpg may not actually be a JPEG image.
It is also important to note that some computers (primarily computers running Windows) do not always display the file extension. It is important to know what extension a file should have. You can do so by right-clicking on that file in your file explorer and choosing “properties.” This will give you information about the file such as its size and what file type it is.
A file is nothing more than a sequence of bytes (explained in more detail in the Hardware chapter). The interpretation of those bytes is what produces, or doesn’t produce, the desired result, such as a Word document or JPEG image. If you save the following JPEG image file and open it using NotePad (Windows), Text Edit (OS X), or Nano (Linux) you would notice that the file opens without generating an error.
The problem with opening the file in one of those programs is that the information in the file is not presented in a way that the user can understand– it is still a representation of the bytes that compose the file. Image viewing/editing software, such as Photoshop or MS Paint, is designed to interpret those bytes and create an image that your eyes and brain can process.
Using NotePad, Text Edit, or Pico, you could remove a block of information from near the bottom of the file or add a bit of your own information, such as your name. If you were then to save the file (in a well behaving piece of software) you would find something that might look something like the following file.
The bottom portion of the image now has a pink tint to it. Also notice that area is not lined up correctly, especially if you look closely at the bushes and the placard in front of the statue. The file was manipulated, the bytes were changed, and the graphics software simply translated the new information into the image.
A virus is created and saved to the file funnypic.exe. For the computer to run the virus program, it must think that the virus is an executable (.exe) file type. If you open the program, the virus infects your computer.
As mentioned before, some operating systems hide file extensions by default in order to save screen space and make the file icons shorter and easier to read. In the above example, the file would most likely appear as funnypic on the user’s screen. This means that users could double-click an icon that installs a virus. One defense against this lies in the icon image. Particular icons are associated with certain file types, such as the recognizable manila folder icon. If there is a file called funnypic.jpg, but the icon displayed is not an image icon, the user should double check the file-type and perform a virus scan.
Virus protection software with real-time scanning will help prevent unwanted .exe files.