tar -cvf <archive>.tar <paths>Creates an uncompressed archive. c = create, v = verbose, f = file name.
Example
tar -cvf backup.tar /etc /home/aliceCreates and extracts archives, with gzip, bzip2, xz or zstd compression.
sudo apt install tartar -cvf <archive>.tar <paths>Creates an uncompressed archive. c = create, v = verbose, f = file name.
Example
tar -cvf backup.tar /etc /home/alicetar -czvf <archive>.tar.gz <paths>gzip compression.
Example
tar -czvf site.tar.gz /var/wwwtar -cJvf <archive>.tar.xz <paths>xz compression: smaller but slower.
Example
tar -cJvf logs.tar.xz /var/logtar --zstd -cvf <archive>.tar.zst <paths>zstd compression: fast and small.
Example
tar --zstd -cvf data.tar.zst data/tar -czvf <archive> --exclude=<pattern> <dir>Leaves out matching paths.
Example
tar -czvf src.tar.gz --exclude=node_modules --exclude=.git project/tar -czpf <archive> -C <dir> .Archives a directory’s contents with relative paths and preserved permissions.
Example
tar -czpf etc.tar.gz -C /etc .tar -xvf <archive>Extracts into the current directory. GNU tar detects compression automatically.
Example
tar -xvf backup.tartar -xzvf <archive> -C <dir>Extracts into a specific directory.
Example
tar -xzvf site.tar.gz -C /tmp/restoretar -xvf <archive> <path>Extracts a single file.
Example
tar -xvf backup.tar etc/hoststar -xvf <archive> --strip-components=1Drops the top-level directory from extracted paths.
Example
tar -xvf tool-1.2.tar.gz --strip-components=1tar -tvf <archive>Lists contents without extracting. Always check archives from untrusted sources for ../ paths first.
Example
tar -tvf backup.tar.gztar -df <archive>Compares an archive against the file system and reports differences.
tar -czf - <dir> | ssh <host> "tar -xzf - -C <dest>"Streams a directory to another machine over SSH without a temporary file.
Example
tar -czf - project | ssh backup "tar -xzf - -C /srv"Copies files and directories, preserving attributes when asked.
Searches the directory tree by name, type, size, time, owner or permissions — and runs actions on matches.
Lists directory contents with sizes, permissions, owners, timestamps and hidden files.
The shell built-in that changes the current directory, including shortcuts for home, previous and parent directories.
Prints the full path of the current working directory, optionally resolving symbolic links.
Moves or renames files and directories.