compress a folder
Pack a folder into one compressed file, look inside it, and unpack it again.
archivesfiles
steps
-
tar -czf folder.tar.gz folder/pack and compress with gzip, fast
-
tar -cJf folder.tar.xz folder/with xz: smaller, slower
-
zip -r folder.zip folder/a zip, for people on Windows
-
tar -tzf folder.tar.gzlist what is inside, without unpacking
-
tar -xzf folder.tar.gzunpack it here
-
unzip folder.zipunpack a zip
notes
lore explain "tar -czf folder.tar.gz folder/"says what each letter does.- GNU tar also does zstd, fast and small:
tar --zstd -cf folder.tar.zst folder/.
commands used
tarzipunzipgzipxz
Each has a page in lore: lore tar opens it.
pack a folder without some files
Make a tar archive of a folder, leaving out folders like node_modules and files like logs.
unpack an archive
Open any common archive: tar, zip, gz, xz, 7z, rar.
add to the end of a file
Add lines to a file without replacing it, also to a file only root can write.
argument list too long
"Argument list too long" from rm, cp or mv: too many files for one command line. Hand them over in batches.