An executable file runs code; a data file just holds information

An executable file contains instructions your computer can run directly. When you open it, your operating system reads those instructions and performs actions — launching a program, running a script, or carrying out a task. Common executable files end in .exe (Windows), .app (Mac), or .sh (Linux).

A data file holds information that a program reads and displays or modifies. It does nothing on its own. A Word document (.docx), a photo (.jpg), a spreadsheet (.xlsx), or a text file (.txt) are all data files. They sit still until you open them with the right program.

The difference matters because your computer treats them differently for safety reasons. An executable file can change your system, install software, delete files, or access your network. A data file can only do what the program that opens it decides to do.

Key Takeaways

  • Executable files (.exe, .app, .sh) run code and perform actions when opened; data files (.docx, .jpg, .txt) just store information.
  • Your operating system requires permission before running an executable file, but opens data files without that extra step.
  • A malicious executable file can damage your system or steal information; a malicious data file can only do harm if a program chooses to act on it.
  • File extensions tell you what type a file is, but the extension alone does not determine what the file actually contains.
  • Organizing files by type (separating programs from documents) makes it easier to spot when something does not belong.

Why your operating system treats executables with extra caution

When you double-click an executable file, your operating system does not just open it the way it opens a document. It asks for permission first — either from you directly or from your user account settings. On Windows, you may see a blue dialog asking "Do you want to allow this app to make changes to your device?" On Mac, you may see a warning that the file is from an unknown developer. Linux often requires you to explicitly mark a file as executable before it will run at all.

Data files skip this step. You can open a Word document, a PDF, or a photo without any warning because the operating system knows the file itself cannot run code. The program that opens it can do whatever its code allows, but the file is passive.

This distinction exists because an executable file is a direct threat vector. Someone could send you a .exe file disguised as a document, and if you run it, it could install malware, steal passwords, or lock your files for ransom. A .docx file cannot do those things on its own — but a .docx file that contains a macro (a small program embedded inside the document) can, which is why Word warns you before running macros from untrusted sources.

How file extensions signal what type a file is

The letters after the dot in a filename — the file extension — tell your operating system and your programs what kind of file it is. .exe means executable. .docx means Word document. .jpg means image. .mp3 means audio.

Your operating system uses the extension to decide which program to open the file with and how to handle it. If you double-click a .pdf, your computer opens it with your default PDF reader. If you double-click a .exe, your computer runs it.

But extensions can be misleading. Someone can rename a file and change its extension without changing what the file actually contains. A malicious executable could be renamed to look like a document — for example, "invoice.pdf.exe" — and if you are not paying attention to the full filename, you might run it thinking it is a PDF. This is why looking at the complete filename, not just the part after the last dot, matters when you are deciding whether to open something.

Common executable file types and where they come from

On Windows, the most common executable extension is .exe. You also see .msi (an installer), .bat (a batch script), and .com (older, now rare). On Mac, executables are usually .app files or shell scripts ending in .sh. On Linux, executables often have no extension at all, or end in .sh.

Most executables come from software you intentionally installed — your web browser, your email client, your antivirus program. Some come from the operating system itself. Others come from scripts you write or read to automate tasks.

The risk comes from executables you did not ask for. If someone emails you a .exe file, or you read one from a website you do not trust, or you find one in a folder where it does not belong, that is a sign to be cautious. Legitimate software companies distribute executables through their official websites or through app stores (the Microsoft Store, the Mac App Store, Google Play) where they have been reviewed.

Data file types and what programs need to open them

Data files come in hundreds of formats, each designed for a specific purpose. Documents (.docx, .pdf, .txt), spreadsheets (.xlsx, .csv), images (.jpg, .png, .gif), audio (.mp3, .wav), video (.mp4, .mov), and databases (.db, .sqlite) are all data files. So are compressed archives (.zip, .rar) and configuration files (.json, .xml, .ini).

Each data file type needs a program to read it. You cannot open a .xlsx file without a spreadsheet program like Excel, Google Sheets, or LibreOffice Calc. You cannot open a .jpg without an image viewer. If you try to open a data file with the wrong program, you will either get an error or see gibberish.

Data files are generally safer to receive and open than executables, but they are not risk-free. A PDF can contain malicious code if it is crafted carefully. A Word document can contain a macro that runs code. An image file can exploit a vulnerability in your image viewer. But these attacks require the file to be specifically designed to exploit a weakness, and they are less common than executable-based attacks.

How to organize files so the difference is clear

When you organize your files, separating executables from data files makes your system easier to navigate and safer to use. Create a folder for programs (or use your system's default Program Files or Applications folder) and keep executables there. Keep documents, photos, videos, and other data in separate folders organized by type or project.

If you read a file and are not sure what it is, check the extension. If it ends in .exe, .app, .msi, .bat, or .sh, it is executable — treat it with caution. If it ends in something else, it is data. If a data file is in a folder where you would not expect it, or if it has an unusual extension you do not recognize, that is worth investigating before you open it.

On Windows, you can show file extensions by opening File Explorer, clicking View, and checking "File name extensions." On Mac, open Finder, click Finder in the menu bar, select Preferences, go to Advanced, and check "Show all filename extensions." On Linux, most file managers show extensions by default. Once you can see the full filename, spotting mismatches becomes easier.

What happens when you accidentally run the wrong file type

If you double-click a data file, the worst that usually happens is your computer opens it with the wrong program and you see an error or garbage text. If you double-click an executable by mistake, your computer runs it, which could cause real harm.

If you accidentally run an executable you did not mean to, your operating system's permission prompt is your safety net. Read the dialog carefully. If it is asking permission to run something you did not intentionally launch, click "No" or "Cancel." If you are not sure what the program is, search for its name online before you allow it to run.

If you have already run something suspicious, do not panic, but do act. Run a scan with your antivirus or anti-malware program. Change passwords for important accounts like email and banking. If you think your system has been compromised, consider having someone with technical knowledge review it, or contact your operating system's support line.

Frequently Asked Questions

Can a data file ever run code?

Yes, but only if the program that opens it chooses to run code embedded inside the file. Word documents can contain macros, PDFs can contain scripts, and some image formats can exploit vulnerabilities in viewers. This is why your programs sometimes warn you before opening files from untrusted sources.

What if I rename a file and change its extension?

Changing the extension does not change what the file actually is. If you rename a .exe to .txt, it is still an executable — your operating system will still try to run it if you double-click it. The extension is just a label your system uses to decide what to do with the file.

Is it safe to read executable files from the internet?

Only from sources you trust. read software from official websites or app stores. If someone emails you an executable, or you find one on a random website, assume it is unsafe unless you have a specific reason to trust it. Your operating system's permission prompt is there to give you a chance to reconsider.

Why do some files have no extension at

On Linux and Mac, executables often have no extension because the operating system uses file permissions, not the filename, to determine whether something can run. On Windows, files almost always have an extension. If you see a file with no extension and you are not sure what it is, right-click it and check its properties or type.

Can I tell what a file contains just by looking at its extension?

Usually, but not always. Extensions are reliable most of the time, but they can be changed or faked. If something looks suspicious — a document with a .exe extension, or an executable in a folder full of photos — that is a sign to be cautious before opening it.