July 19, 2022

RHEL 9.0 Archieve and Compress Using tar with gunzip, bzip2 and xz

$ sudo dnf install tar bzip2

$ man tar
...
    -c or --create : Create an archive file.
    -t or --list : List the contents of an archive.
    -x or --extract : Extract an archive.

   Compression options
       -z, --gzip, --gunzip, --ungzip
              Filter the archive through gzip(1).
       -j, --bzip2
              Filter the archive through bzip2(1).
       -J, --xz
              Filter the archive through xz(1).
       -Z, --compress, --uncompress
              Filter the archive through compress(1).

       -p, --preserve-permissions, --same-permissions
              extract information about file permissions (default for superuser)

   Extended file attributes
       --acls Enable POSIX ACLs support.
       --no-acls
              Disable POSIX ACLs support.
       --selinux
              Enable SELinux context support.
       --no-selinux
              Disable SELinux context support.
       --xattrs
              Enable extended attributes support.

       -C, --directory=DIR
              Change to DIR before performing any operations.  This option is order-sensitive, i.e. it affects all options that follow.
...

$ tar -cvf mybackup.tar anaconda-ks.cfg FOO
$ tar -czvf mybackup.tar.gz anaconda-ks.cfg FOO /etc
$ tar -cjvf mybackup.tar.bz2 anaconda-ks.cfg FOO
$ tar -cJvf mybackup.tar.xz anaconda-ks.cfg FOO

$ tar -tvf mybackup.tar
$ tar -tzvf mybackup.tar.gz
$ tar -tjvf mybackup.tar.bz2
$ tar -tJvf mybackup.tar.xz
$ tar -tJvf backup.tar.xz

$ tar -xzvf backup.tar.gz -C /tmp

No comments: