Linux File Types Explained: Binary, Executable, Source, and Text Files

When working with Linux, DevOps, or development tools, you'll often encounter terms like binary files, executable files, source files, and more. These terms are easy to confuse, especially if you're new to the command line or scripting.
In this blog post, I’ll break down these file types clearly with real examples, commands, and a comparison table so you understand the differences and how they apply to real-world DevOps or Linux tasks.
📦 1. What Is a Binary File?
A binary file is a file that contains machine-readable data — not human-readable text.
These are typically:
Compiled programs (e.g.,
/bin/ls,a.out)Images, videos (
.jpg,.mp4)Libraries (
.so,.dll)Disk images (
.iso,.img)
🔍 How to identify a binary file:
file /bin/ls
# ELF 64-bit LSB executable, x86-64...
The file command tells you that this is a compiled ELF binary, meaning it’s ready to run on your Linux system.
⚙️ 2. What Is an Executable File?
An executable file is a file that the operating system can run as a program.
Executables include:
Compiled binaries (e.g.,
/usr/bin/ls)Scripts with a shebang (
#!/bin/bashor#!/usr/bin/python3)
✅ For a file to be executable in Linux:
It must have the
xpermission (chmod +x)It must be a binary or a script with a valid interpreter
🔧 Example:
chmod +x myscript.sh # Make the script executable
./myscript.sh # Run it
✏️ 3. What Is a Source File?
A source file contains code written in a programming language and needs to be interpreted or compiled.
Examples:
.c,.cpp→ compiled to binaries usinggcc.java→ compiled to bytecode.py,.sh→ interpreted usingpythonorbash
Source files are not executable by default unless:
You run them via an interpreter:
pythonscript.pyOr you add execution permission:
chmod +xscript.shwith a shebang at the top
🔤 4. What Is a Text File?
A text file is simply a human-readable file. It includes:
.txt,.md,.yamlConfig files like
.confCode files before they are compiled
These can be viewed using cat, less, or a text editor.
🧩 5. What Is an Object File?
Object files are the result of compiling source code, but not yet linked into an executable.
Example:
gcc -c program.c -o program.o
.ofiles are intermediate binariesNot directly executable
🗃️ 6. What Are Library Files?
These are not standalone programs, but collections of compiled functions that other programs can use.
Shared Libraries:
.so(Linux),.dll(Windows)Static Libraries:
.a(Linux),.lib(Windows)
They're used at runtime or compile time, depending on the type.
📊 Summary Table
| File Type | Description | Extension(s) | Executable? | Human-readable? |
| Binary File | Machine-readable, compiled data | .bin, .out, .so | Sometimes | ❌ |
| Executable File | Can be run by OS as a program | Any (e.g., no ext, .sh) | ✅ | Depends (binary or script) |
| Text File | Plain, readable data or code | .txt, .md, .conf | ❌ | ✅ |
| Source File | Code written in programming languages | .c, .cpp, .py | ❌ (unless made so) | ✅ |
| Object File | Compiled but not linked code | .o | ❌ | ❌ |
| Library File | Shared or static library files | .so, .a | ❌ (used by executables) | ❌ |
🛠️ Bonus Commands You Should Know
📁 View file type:
file mybinary
👁️ View permissions:
ls -l
🔓 Make a file executable:
chmod +x script.sh
🚀 Run a binary or script:
./myprogram
./myscript.sh
🧠 Conclusion
Understanding the difference between binary, executable, text, and source files is important whether you're writing scripts, deploying containers, or troubleshooting DevOps pipelines. Knowing when and how to apply execution permissions, or when a file needs to be compiled or interpreted, can save you hours of debugging.






