Cara membuat dan mengekstrak file arsip atau .tar menggunakan perintah linux
tar option(s) archive_name file_name(s)
# Importnt flags: -c instructs tar to create
# -f instructs tar that the next argument is the new archive file name
tar -cf filename.tar file1 file2 file3
# -v displays a list of the files that are included in the archive while archiving
tar -cvf file.tar file1 file2 file3
# To make archives from the contents of one or more directories.
# The result is recursive;
# it includes all the content of the listed directories
tar -cvf dir.tar dir1 dir2
# tar with a wildcard
tar -cf file.tar *
# To remove or delete the files after adding them to archive
tar -cvf file.tar --remove-files file1 file2 file3
# tar command does not compress.
# The file can be compressed after archiving using gzip or equivalent.
# or with a tar option
# To compress use any of these suitable options
# -j (for bzip2), -z (for gzip) or -Z (for compress).
tar -cvzf files.tar.gz file4 file5 file6
# command to extract or unpack tar or archive files;
tar -xf file.tar
# Check if there's enough storage space.
# Unpack in a new or empty directory
# Decompress with the appropriate program if compressed.
# To run verbose use -v
tar -xvf file.tar
# To automatically decompress tar files prior to extraction,
# -j (for bzip2 compressed file), -z (for gzip compressed file)
tar -xjvf files.tar.bz2
# OR
tar -xzvf files.tar.gz
# command to extract an archive file to a specified directory
tar -xvf file.tar -C <destination-directory>
# To add a file to an existing archive use the -r option.
tar -rf file.tar <filename>
# The --delete option allows specified files to be completely removed from a tar
tar -f file.tar --delete file1 file2
# The -t option tells tar to list the contents of an uncompressed archive without performing an extraction.
tar -tf file.tar
Chris Nzoka-okoye