Site icon Ananova Business Web Hosting

Linux Archive for Files and Directory

Linux Archive

Compress

To rip a collection of files and directories into highly compressed archive file commonly called tarball or tar, gzip and bzip.

tar (tape archive) command

tar [-] A –catenate –concatenate | c –create | d –diff –compare | –delete | r –append | t –list | –test-label | u –update | x –extract –get [options] [pathname …]

-cvf: Combines specified filenames into a single archive file

-c: Creates Archive
-v: Displays Verbose Information
-f: creates an archive with a given filename

Uncompressed files have the file ending .tar.

tar cvf <filename>.tar <filenames>
tar cvf ananova.tar /home/ananova/public_html

-z: zip, tells tar command that create tar file using gzip

It is fast for creating and extracting files. Files with gz compression have the file ending .tar.gz or .tgz.

tar czf<filename>.tar.gz <filenames>

tar cvzf ananova.tar.gz /home/ananova/public_html

-j: filter archive tar file using tbzip

Creating compressed tar archive file in Linux using option -j ‘.tar.tbz': It compresses and creates archive file less than the size of the gzip but takes more time then gzip.

tar cvfj ananova.tar.tbz /home/ananova/public_html

-x: Extract the archive

tar xvf <filename>.tar
tar xvf ananova.tar

Extracting a gzip tar Archive *.tar.gz using option -xvzf

tar xvzf ananova.tar.gz

-u: archives and adds to an existing archive file. It appends files, but only those that are newer than the copy in the archive.
-A: Concatenates the archive files

-W: Verify an archive file
-r: update or add file or directory in already existed .tar file
–exclude: for each directory or file you want to exclude

-t: displays or lists files in an archived file

–wildcards: to interpret wildcards in the name of the files to be extracted

tar tvf ananova.tar --wildcards '*.png'

This will extract only files with the extension .png from the archive file.tar. The filename (*.png) is enclosed in single-quotes to protect the wildcard (*) from being expanded incorrectly by the shell.


Exit mobile version