-
-
Notifications
You must be signed in to change notification settings - Fork 3
Linux file Guide
Mattscreative edited this page Nov 20, 2025
·
3 revisions
Complete beginner-friendly guide to file on Linux, covering Arch Linux, CachyOS, and other distributions including file type detection, file identification, and MIME types.
file determines file type.
Uses:
- File type: Identify file type
- MIME type: Get MIME type
- File identification: Determine file format
- Debugging: Troubleshoot file issues
Why it matters:
- File identification: Know file type
- Scripts: Process files correctly
- Security: Verify file types
Basic usage:
# Identify file type
file file.txt
# Output: file.txt: ASCII textCheck several:
# Multiple files
file file1.txt file2.bin file3.jpg
# Type for eachMore details:
# Brief description
file -b file.txt
# -b = brief (no filename)Get MIME:
# MIME type
file -i file.txt
# Shows MIME typeMIME format:
# MIME type only
file --mime-type file.txt
# Or
file -i file.txtUse in scripts:
#!/bin/bash
MIME=$(file -i file.txt | cut -d: -f2)
echo "MIME type: $MIME"Check installation:
# Check file
which file
# Install if missing
sudo pacman -S fileThis guide covered file usage, file type detection, and MIME types for Arch Linux, CachyOS, and other distributions.
- stat Guide - File statistics
- ls Guide - List files
-
file Documentation:
man file
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.