Windows
Linux
File Management
Archives & Compression
Windows tar.exe -cf equivalent in Linux
Combines files and directories into a TAR archive without necessarily compressing them.
Windows
→
tar.exe -cf
Linux equivalents
tar -cf archive.tar folder/
tar -cf archive.tar folder/
tar -cf archive.tar folder/
Overview
What this command does
Combines files and directories into a TAR archive without necessarily compressing them.
Migration tip:
tar is available on modern Windows and Linux, but Linux users commonly combine it with gzip or xz using -z or -J.Practical tasks
Common use cases
Create a TAR archive
Combines files and directories into a TAR archive without necessarily compressing them.
tar -cf archive.tar folder/
Create an uncompressed TAR archive
tar -czf archive.tar.gz folder/
Create a gzip-compressed TAR archive
tar -cJf archive.tar.xz folder/
Create an xz-compressed TAR archive
Ready to run
Copyable Linux commands
Review paths, device names, package names and permissions before running any command.
tar -cf archive.tar folder/
tar -czf archive.tar.gz folder/
tar -cJf archive.tar.xz folder/
Walkthrough
Examples with explanations
tar -cf archive.tar folder/ # create a plain TAR archive
tar -czf archive.tar.gz folder/ # create a compressed tar.gz archive
tar -cJf archive.tar.xz folder/ # create a highly compressed tar.xz archive
Reference
Common options and variations
| Command or option | Use |
|---|---|
tar -cf archive.tar folder/ | Create an uncompressed TAR archive |
tar -czf archive.tar.gz folder/ | Create a gzip-compressed TAR archive |
tar -cJf archive.tar.xz folder/ | Create an xz-compressed TAR archive |
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 | tar -cf archive.tar folder/ |
Same command on this distribution. |
| Fedora | same command | tar -cf archive.tar folder/ |
Same command on this distribution. |
| Arch | same command | tar -cf archive.tar folder/ |
Same command on this distribution. |
Keep learning