TAR(1) General Commands Manual TAR(1) (NAME) tar - (SYNOPSIS) tar [bundled-flags ] [ | ...] tar {-c} [options] [files | directories] tar {-r | -u} -f archive-file [options] [files | directories] tar {-t | -x} [options] [patterns] (DESCRIPTION) tar . cdrom ISO 9660 tar pax cpio zip jar ar xar rar rpm 7-zip tar pax cpio ar zip 7-zip shar . "bundled" . . (COMPATIBILITY) . . tar : -c . --create . -r -c . . -f . --append . -t stdout. --list. -u -r, . . -f . --update. -x . () . --extract. -c, -r, -u, . . . . (globbing) tcsh(1). (OPTIONS) . @archive ( c r) . tar -c -f - newfile @original.tar newfile original.tar. tar -c -f - newfile original.tar . tar -czf - --format pax @- ( ) pax gzip . tar . -a, --auto-compress ( c) . tar -a -cf archive.tgz source.c source.h pax gzip tar -a -cf archive.tar.bz2.uu source.c source.h pax bzip2 uuencode tar -a -cf archive.zip source.c source.h zip tar -a -jcf archive.tgz source.c source.h "-j" pax gzip tar -a -jcf archive.xxx source.c source.h pax bzip2 . --acls ( c r u x) ACL POSIX.1e NFSv4. --no-acls c r u ( Mac OS X) tar x root . Mac OS X ACL ACL NFSv4 . ACL --mac-metadata . -B, --read-full-blocks tar(1) . -b blocksize, --block-size blocksize 512 / . 20 (10240 ) . -C directory, --cd directory, --directory directory c r . x . --chroot ( x) chroot() -C . --clamp-mtime ( --mtime) --mtime. --clear-nochange-fflags ( x) . --exclude pattern . . --exclude-vcs : `Arch', `Bazaar', `CVS', `Darcs', `Mercurial', `RCS', `SCCS', `SVN' `git'. --fflags ( c r u x) . --no-fflags c r u tar x root . --format format ( c r u) . : "cpio", "pax", "shar", "ustar". libarchive-formats(5) . r u . -f file, --file file . - . FreeBSD /dev/sa0 /dev/st0 . --gid id . . --gname . --gname name . ( --gid) . . --group name[:gid] gid name . --gname . -H ( c r) . -h ( c r) -L. -I -T. --help . --hfsCompression ( x) Mac OS X ( 10.6 ). HFS+ . --ignore-zeros --options read_concatenated_archives GNU tar. --include pattern . --exclude . . --include . tar -c -f new.tar --include='*foo*' @old.tgz new.tar old.tgz `foo'. -J, --xz ( c) xz(1). . tar XZ . -j, --bzip, --bzip2, --bunzip2 ( c) bzip2(1). . tar bzip2 . -k, --keep-old-files ( x) . . --keep-newer-files ( x) . -L, --dereference ( c r) . . . -l, --check-links ( c r) . --lrzip ( c) lrzip(1). . tar lrzip . --lz4 ( c) lz4 . . tar lz4 . --zstd ( c) zstd . . tar zstd . --lzma ( c) LZMA . . --xz . tar LZMA . --lzop ( c) lzop(1) . . tar LZO . -m, --modification-time ( x) . . --mac-metadata ( c r u x) Mac OS X. ACL copyfile(3) AppleDouble. --no-mac-metadata. c r u tar x root . pax ( pax restricted tar bsdtar) --mtime date ( c r u) . -n, --norecurse, --no-recursion . --newer date ( c r u) . ctime . --newer-mtime date ( c r u) --newer, ctime mtime . --newer-than file ( c r u) . ctime . --newer-mtime-than file ( c r u) --newer-than, ctime mtime . --nodump ( c r) nodump . --nopreserveHFSCompression ( x) Mac OS X ( v10.6 ). HFS+ . HFS+ . --null ( -I -T) null . -print0 find(1). --no-acls ( c r u x) ACL POSIX.1e NFSv4 . --acls tar root x ( Mac OS X c r u x). --no-fflags ( c r u x) . --fflags tar root x . --no-mac-metadata ( c r u x) Mac OS X. ACL copyfile(3) AppleDouble . --mac-metadata. tar root x . --no-read-sparse ( c r u) (sparse) . --read-sparse. --no-safe-writes ( x) rename(2) . --safe-writes . --no-same-owner ( x) . --same-owner tar root . --no-same-permissions ( x) (SGID SUID (sticky bit) ACL) . -p tar root . --no-xattrs ( c r u x) . --xattrs tar root x . --numeric-owner --uname "" --gname "". . . -O, --to-stdout ( x t) (-x) . (-t) stderr . -o ( x) . -p root . ACL . -o ( c r u) --format ustar --older date ( c r u) . ctime . --older-mtime date ( c r u) --older, ctime mtime . --older-than file ( c r u) . ctime . --older-mtime-than file ( c r u) --older-than, ctime mtime . --one-file-system ( c r u) . --options options . . . : key=value . . key . key=1. !key . module:key=value, module:key, module:!key module. archive_write_set_options(3) archive_read_set_options(3). : iso9660:joliet Joliet. !joliet iso9660:!joliet . iso9660:rockridge Rock Ridge. !rockridge iso9660:!rockridge . gzip:compression-level 1 9 gzip . gzip:timestamp . !timestamp gzip:!timestamp . lrzip:compression=type type . bzip2 gzip lzo ( ) zpaq ( ). lrzip:compression-level 1 9 lrzip . lz4:compression-level 1 9 lzop . lz4:stream-checksum . lz4:!stream-checksum . lz4:block-checksum ( ). lz4:block-size 4 7 lz4 ( 7 ). lz4:block-dependence . zstd:compression-level=N zstd . 1 22 . zstd:threads=N 0 CPU . zstd:frame-per-file . zstd:min-frame-in=N zstd:frame-per-file, N . k / kB, M / MB, G / GB . zstd:min-frame-out=N, zstd:min-frame-size=N zstd:frame-per-file, N . k / kB, M / MB, G / GB . zstd:max-frame-in=N, zstd:max-frame-size=N N . k / kB, M / MB, G / GB . 1,024 . zstd:max-frame-out=N N . k / kB, M / MB, G / GB . 1,024 . lzop:compression-level 1 9 lzop . xz:compression-level 0 9 xz . xz:threads . threads 0 xz(1) CPU . mtree:keyword mtree mtree . : cksum, device, flags, gid, gname, indent, link, md5, mode, nlink, rmd160, sha1, sha256, sha384, sha512, size, time, uid, uname. : "device, flags, gid, gname, link, mode, nlink, size, time, type, uid, uname". mtree:all . mtree:!all . mtree:use-set /set . mtree:indent 80 . zip:compression=type type . store () deflate ( gzip). zip:encryption zip. zip:encryption=type type . zipcrypt ( zip) aes128 ( WinZip AES-128) aes256 ( WinZip AES-256). read_concatenated_archives tar . . -i, --ignore-zeros GNU tar . . -P, --absolute-paths . ( / ) . tar .. . . -p, --insecure, --preserve-permissions ( x) . ACL . --no-same-permissions tar root . : --no-acls, --no-fflags, --no-mac-metadata --no-xattrs. --passphrase passphrase passphrase . zip . . --posix ( c r u) --format pax -q, --fast-read ( x t) . . . . --read-sparse ( c r u) . --no-read-sparse . -S ( x) . NULL (seek ). conv=sparse dd . -s pattern pattern . /old/new/[bghHprRsS] old new . old . new, ~ \1 \9 . g . s . p . b . H R S . h r s . hrs . h r s . --safe-writes ( x) . tar ( ) (unlink) . . --safe-writes tar rename(2) . . --same-owner ( x) . --no-same-owner tar root . --strip-components count . . / . -T filename, --files-from filename x t tar filename . c tar filename . "-C" . --null . --null "-C" . : find(1) -n . --totals ( c r u) stderr . -U, --unlink, --unlink-first ( x) (unlink) . . tar . SECURITY . --uid id . --uname . --uname name . ( --uid ) . . --use-compress-program program ( x t) ( c) program (pipe) . --owner name[:uid] uid name . --uname . -v, --verbose (verbose) . tar . tar ls(1) . -v ls . --version tar libarchive . -w, --confirmation, --interactive . -X filename, --exclude-from filename . --exclude . --xattrs ( c r u x) . --no-xattrs c r u tar x root . -y ( c) bzip2(1) . . tar bzip2 . -Z, --compress, --uncompress ( c) compress(1) . . tar compress . -z, --gunzip, --gzip ( c) gzip(1) . . tar gzip . (ENVIRONMENT) tar : TAR_READER_OPTIONS . --options . TAR_WRITER_OPTIONS . --options . LANG (locale) . environ(7) . TAPE . -f . -f . TZ . environ(7) . (EXIT STATUS) The tar utility exits 0 on success, and >0 if an error occurs. (EXAMPLES) file.tar.gz source.c source.h : tar -czf file.tar.gz source.c source.h : tar -tvf file.tar.gz : tar -x ISO 9660 cdrom: tar -tf image.iso tar : tar -cf - -C srcdir . | tar -xpf - -C destdir : cd srcdir ; tar -cf - . | (cd destdir ; tar -xpf -) -Cfoo/baz @archive-file . tar -c -f new.tar foo1 @old.tgz -C/tmp foo2 new.tar . tar foo1 . old.tgz . /tmp foo2 . mtree(5) : $ cat input.mtree #mtree usr/bin uid=0 gid=0 mode=0755 type=dir usr/bin/ls uid=0 gid=0 mode=0755 type=file content=myls $ tar -cvf output.tar @input.mtree --newer --newer-mtime "12 Mar 2005 7:14:29pm", "2005-03-12 19:14", "5 minutes ago", "19:14 PST May 1". --options . mtree type, time, uid : tar -cf file.tar --format=mtree --options='!all,type,time,uid' dir gzip xz : tar -czf file.tar --options='compression-level=9'. API archive_read_set_options() archive_write_set_options() archive_read(3) archive_write(3) . (COMPATIBILITY) . ( - ) . . . tar tbf 32 file.tar t, b, f . b f . 32 b file.tar f . c r t u x b f l m o v w SUSv2 . tar c, t, x b, f, m, v, w . tar . (SECURITY) tar . tar . . superuser . . tar : o . tar / . o .. . tar .. . o . . tar . . -U . -U -P tar . . tar -tf filename . -k tar -U . (super- user) . -P tar .. . (SEE ALSO) bzip2(1), compress(1), cpio(1), gzip(1), mt(1), pax(1), shar(1), xz(1), libarchive(3), libarchive-formats(5), tar(5) (STANDARDS) POSIX tar ISO/IEC 9945-1:1996 ("POSIX.1") IEEE Std 1003.1-2001 ("POSIX.1"). tar POSIX tar POSIX pax . ustar pax IEEE Std 1003.1-2001 ("POSIX.1") pax . (HISTORY) tar Seventh Edition Unix . . pdtar ( ) GNU tar . GNU tar tar FreeBSD FreeBSD 1.0. libarchive(3) . FreeBSD 5.4 . (BUGS) -l ISO/IEC 9945-1:1996 ("POSIX.1") . GNU tar 1.15 -l --one-file-system . -C dir . . (pad) . tar cpio . . gzip(1) bzip2(1), tar, (null padding) . tar -czf - file tar -cf - file | gzip / ( POSIX) . r u . c @archive-file . @foo -foo ./@foo ./-foo . ./ . / -P . . . ( tar cpio) @- . . Linux 6.12.107+deb13-amd64 April 23, 2024 Linux 6.12.107+deb13-amd64