Skip to main content

Command Palette

Search for a command to run...

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

Published
4 min read
Linux File Types Explained: Binary, Executable, Source, and Text Files
J
IT Professional with 4+ years of combined experience across Software Engineering, DevOps, Cloud, Technical Writing, and AI-assisted Development. Passionate about building things, simplifying complex technology, and continuously learning while sharing knowledge through hands-on experimentation and technical writing.

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/bash or #!/usr/bin/python3)

For a file to be executable in Linux:

  • It must have the x permission (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 using gcc

  • .java → compiled to bytecode

  • .py, .sh → interpreted using python or bash

Source files are not executable by default unless:

  • You run them via an interpreter:
    python script.py

  • Or you add execution permission:
    chmod +x script.sh with a shebang at the top


🔤 4. What Is a Text File?

A text file is simply a human-readable file. It includes:

  • .txt, .md, .yaml

  • Config files like .conf

  • Code 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
  • .o files are intermediate binaries

  • Not 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 TypeDescriptionExtension(s)Executable?Human-readable?
Binary FileMachine-readable, compiled data.bin, .out, .soSometimes
Executable FileCan be run by OS as a programAny (e.g., no ext, .sh)Depends (binary or script)
Text FilePlain, readable data or code.txt, .md, .conf
Source FileCode written in programming languages.c, .cpp, .py❌ (unless made so)
Object FileCompiled but not linked code.o
Library FileShared 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.

More from this blog

D

Demystifying Tech with Jasai

102 posts

Demystifying Tech with Jasai is a blog dedicated to breaking down complex tech concepts into clear, beginner-friendly explanations. Covering DevOps, Docker, Git, AWS, CI/CD, Networking, and core programming fundamentals, it emphasizes strong foundations before advanced topics. Through step-by-step walkthroughs and real-world analogies, it simplifies the why behind the how — making technology approachable, structured, and built for long-term growth.