tar

Linux · Files · available in the simulator

What it does

Archive files and directories. When combined with -z (gzip) or -j (bzip2), it also compresses.

Syntax

tar [opciones] [archivo.tar] [archivos...]

Options and parameters

  • -c

    Create a new archive.

    tar -czvf copia.tar.gz carpeta/
  • -x

    Extract files from an archive.

    tar -xzvf copia.tar.gz
  • -t

    List the contents of an archive.

  • -v

    Verbosely list files processed.

  • -f

    Use archive file; must immediately precede the archive name.

  • -z

    Filter the archive through gzip.

  • -j

    Filter the archive through bzip2.

  • -J

    Filter the archive through xz.

  • -C

    Change to directory before performing operations.

    tar -xzf copia.tar.gz -C /tmp
  • --exclude

    Exclude files matching pattern.

Usage examples

  • tar -cvf fichero.tar carpeta
  • tar -tvf fichero.tar
  • tar -xvf fichero.tar
  • tar -zcvf fichero.tar.gz carpeta
  • tar -jcvf fichero.tar.bz2 carpeta
  • tar -czf backup.tar.gz carpeta/
  • tar -xzf backup.tar.gz
  • tar -czvf copia.tar.gz carpeta/
  • tar -xzvf copia.tar.gz
  • tar -xzf copia.tar.gz -C /tmp
Practise tar

Related commands