Original post
THE ULTIMATE GUIDE TO FILE FORMATS
How to identify, open, extract, and execute any file across Windows, Linux, and macOS.
How to identify, open, extract, and execute any file across Windows, Linux, and macOS.
1. Introduction
Ever downloaded a file and had no idea what program to use, or how to run it via terminal? File extensions tell your operating system what type of data is inside a file and which software should handle it. Below is a complete reference guide covering archives, executables, scripts, disk images, and source code.
Pro Tip: Always enable "File name extensions" in your File Explorer / Finder settings so you never get tricked by double extensions (e.g.,invoice.pdf.exe).
2. Archives & Compressed Files
Used to bundle multiple files together and reduce file size.
- .zip – Universal archive. Supported natively by Windows, macOS, and Linux.
- .rar – Proprietary archive format. Requires WinRAR (Windows), The Unarchiver (macOS), or
unrar(Linux). - .7z – High-compression open-source format. Best opened with 7-Zip.
- .tar.gz / .tgz – Standard Linux compressed tarball.
- .tar.xz / .tar.bz2 – High-ratio Linux compressed archives.
How to extract via Bash / Terminal (Linux & macOS):
bash
# Extract a .zip file
unzip filename.zip -d /path/to/destination/
# Extract a .tar.gz file
tar -xvzf filename.tar.gz
# Extract a .tar.xz file
tar -xvJf filename.tar.xz
# Extract a .7z file (requires p7zip)
7z x filename.7z
# Extract a .rar file (requires unrar)
unrar x filename.rar3. Executables & Installers
Files designed to run programs or install software directly on your system.
| Extension | Operating System | How to Execute / Run |
|---|---|---|
.exe | Windows | Double-click to run, or type start filename.exe in CMD. |
.msi | Windows | Windows Installer package. Double-click or run msiexec /i file.msi. |
.dmg / .pkg | macOS | Double-click to mount disk image (.dmg) or launch installer (.pkg). |
.deb | Debian / Ubuntu | Install via terminal using sudo dpkg -i file.deb. |
.rpm | Fedora / RHEL | Install via terminal using sudo rpm -i file.rpm. |
.AppImage | Universal Linux | Portable app. Give execution permission and run directly. |
Running Linux Binaries & AppImages via Bash:
bash
# Step 1: Grant execution permissions to the file
chmod +x program.AppImage
# Step 2: Execute the file
./program.AppImage
# Installing a .deb package and fixing missing dependencies
sudo dpkg -i package.deb
sudo apt-get install -f4. Scripts & Command-Line Files
Text files containing instructions executed by an interpreter or shell.
- .sh – Linux/Unix Shell Script.
- .bat / .cmd – Windows Batch Script.
- .ps1 – Windows PowerShell Script.
- .py – Python Script.
- .js – JavaScript (Node.js) Script.
Execution Examples (Bash, CMD & PowerShell):
bash
# Linux / macOS: Run a Bash script
chmod +x script.sh
./script.sh
# Run a Python script (Cross-platform)
python3 script.py
# Run a Node.js script (Cross-platform)
node app.jsWindows PowerShell Execution (if scripts are blocked):
powershell
# Bypass execution policy for the current session and run script
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
.\script.ps15. Disk Images & Virtual Machines
Exact copies of optical discs, hard drives, or virtual environments.
- .iso – Standard CD/DVD/OS image. Windows 10/11 and macOS can mount these natively by double-clicking. Use Rufus or BalenaEtcher to flash them to a USB drive.
- .img – Raw disk image. Commonly used for Raspberry Pi or embedded systems.
- .vmdk / .vdi / .qcow2 – Virtual hard disks used in VMware, VirtualBox, and QEMU/KVM.
Mounting an ISO in Linux via Terminal:
bash
# Create a mount point directory
sudo mkdir -p /mnt/iso
# Mount the ISO file
sudo mount -o loop image.iso /mnt/iso
# Unmount when finished
sudo umount /mnt/iso6. Unknown Files? How to Identify Any File
If a file has no extension or an unrecognizable one, you can inspect its Magic Bytes (file header) to discover what it actually is.
Using the
file command in Linux / macOS / Git Bash:bash
# Check the true file type regardless of its extension
file mysterious_file
# Output example: "mysterious_file: ELF 64-bit LSB executable, x86-64" or "Zip archive data"Click here for Windows CMD / PowerShell Method
In Windows PowerShell, you can read the first few bytes (Hex header) of an unknown file to identify it:
powershell
Format-Hex -Path .\unknown_file -Count 164D 5A(MZ) = Windows Executable (.exe / .dll)50 4B 03 04(PK) = ZIP Archive (or .docx, .xlsx, .apk, .jar)25 50 44 46(%PDF) = PDF Document7F 45 4C 46(.ELF) = Linux Executable
Hope this guide helps! Feel free to reply below if you have a specific file format you need help opening.
