Windows
Linux
File Management
File System
Windows fsutil file createnew equivalent in Linux
Creates an empty or preallocated file with a specific size.
Windows
→
fsutil file createnew
Linux equivalents
truncate -s 100M test.img
truncate -s 100M test.img
truncate -s 100M test.img
Overview
What this command does
Creates an empty or preallocated file with a specific size.
Migration tip:
truncate changes the apparent file size. fallocate reserves real disk blocks and is better for testing storage allocation.Practical tasks
Common use cases
Create a file of a chosen size
Creates an empty or preallocated file with a specific size.
truncate -s 100M test.img
Create a sparse 100 MB file
fallocate -l 1G disk.img
Allocate a real 1 GB file
truncate -s 0 logfile.txt
Empty a file without deleting it
Ready to run
Copyable Linux commands
Review paths, device names, package names and permissions before running any command.
truncate -s 100M test.img
fallocate -l 1G disk.img
truncate -s 0 logfile.txt
Walkthrough
Examples with explanations
truncate -s 100M test.img # create a sparse 100 MB file
fallocate -l 1G disk.img # allocate 1 GB of disk space
truncate -s 0 logfile.txt # clear a file while keeping it
Reference
Common options and variations
| Command or option | Use |
|---|---|
truncate -s 100M test.img | Create a sparse 100 MB file |
fallocate -l 1G disk.img | Allocate a real 1 GB file |
truncate -s 0 logfile.txt | Empty a file without deleting it |
Distro differences
Debian/Ubuntu vs Fedora vs Arch
This command is the same on Debian/Ubuntu, Fedora and Arch Linux when the relevant tool is installed.
| Distribution | Package manager / base | Equivalent command | Difference to notice |
|---|---|---|---|
| Debian/Ubuntu | same command | truncate -s 100M test.img |
Same command on this distribution. |
| Fedora | same command | truncate -s 100M test.img |
Same command on this distribution. |
| Arch | same command | truncate -s 100M test.img |
Same command on this distribution. |
Important
What to watch out for
Sparse files can appear large while consuming little disk space. Use du -h and ls -lh together to compare allocated and apparent size.
Keep learning