File Size Basics
Understanding File Sizes in Linux
In Linux systems, file sizes are typically measured in bytes, with common units including:
Unit |
Abbreviation |
Equivalent |
Byte |
B |
1 byte |
Kilobyte |
KB |
1,024 bytes |
Megabyte |
MB |
1,024 KB |
Gigabyte |
GB |
1,024 MB |
File Size Representation
graph LR
A[File Size] --> B[Bytes]
A --> C[Human-Readable Format]
B --> D[Exact Numeric Value]
C --> E[KB/MB/GB]
Checking File Sizes
Linux provides multiple commands to check file sizes:
1. ls Command
## Basic file size display
ls -l filename
## Human-readable file sizes
ls -lh filename
2. du Command
## Check file size
du -h filename
## Check directory size
du -sh /path/to/directory
3. stat Command
## Detailed file information
stat filename
File Size Limitations
Different filesystems have varying file size limits:
Filesystem |
Max File Size |
FAT32 |
4 GB |
NTFS |
16 EB (Exabytes) |
ext4 |
16 TB |
Key Considerations
- File sizes impact storage and performance
- Large files require efficient management
- Different use cases demand specific file size strategies
At LabEx, we recommend understanding these fundamentals before creating large files in bash.