Linux Linux Basics by Editorial Staff February 24, 2023 written by Editorial Staff February 24, 2023 File Compression and Archiving The compress and archive files is useful a group of files store to in one file system for easy backup. And easy to transfer files to another directory or another computer. It is uses to less disk space and download faster via the Internet. If disk space is a concern, compress rarely-used files, or place all such files in a single archive file and compress it. An archive file is not compressed file, but a compressed file can be an archive file. A Compressed file: A compressed file is a collection of files or directories that are stored in one file. It is compressed large files. Compression is the process of reducing the size depending upon the original file. Red hat Linux provides the bzip2, gzip and zip tools for compression from a shell prompt. Here the zip and unzip tools are well supported to all major and minor operating system. If you transfer files between Linux and other operating system such as MS Windows, use zip tool. Compressed tools: if you compressed any file with bzip2 the file extant should be .bz2. if you compressed any file with gzip the file extant should be .gz. if you compressed any file with zip the file extant should be .zip. decompression tools: bzig2 means bunzip gzip means gunzip zip means unzin How to compressed file? bzip2: [root@localhost redhat]# bzip2 myfile [root@localhost redhat]# gzip: [root@localhost redhat]# gzip dba [root@localhost redhat]# zip: [root@localhost redhat]# zip dba.zip dba adding: dba (deflated 48%) [root@localhost redhat]# How to decompressed file? bzip2: [root@localhost redhat]# bunzip2 myfile.bz2 [root@localhost redhat]# gzip: [root@localhost redhat]# gunzip dba.gz [root@localhost redhat]# unzip: [root@localhost redhat]# unzip dba.zip Archive: dba.zip replace dba? [y]es, [n]o, [A]ll, [N]one, [r]ename: y inflating: dba [root@localhost redhat]# An archive file: An archive files is a collection of file or directories stored in one file. Archiving is the process of combining multiple files and directories (same or different sizes) into one file. The most common programs for archiving files and directories are Tar and Zip. A Tar file is a collection of several files and directories in on file. This is a good way to create backups and archives. Syntax: $tar [options] [archive-files] [files or directory to be archived] There are some Tar options -c: to create a new archive -v: verbose information -f: to create archive filename -t: to show tar file content -r: to append files to the end of an archive -z: to compressed the tar file with gzip -j: to compressed the tar file with bzip2 -x: to extract file from an archive –wildcards: to specify patterns in Unix tar command How to create a tar file? [root@localhost redhat]# tar -cvf linuxdb.tar kiran mifile music kiran mifile music [root@localhost redhat]# What contains linuxdb.tar file? [root@localhost redhat]# tar -tvf linuxdb.tar -rw-r--r-- root/root 0 2021-08-09 15:10 kiran -rw-r--r-- root/root 2599 2021-08-10 12:30 mifile -rw-r--r-- root/root 0 2021-08-09 15:10 music [root@localhost redhat]# How to extracts for sources? [root@localhost redhat]# tar -xvf linuxdb.tar mifile mifile [root@localhost redhat]# How to append? [root@localhost redhat]# tar -rvf linuxdb.tar subhan subhan [root@localhost redhat]# How to combined compression files and archive files? [root@localhost redhat]# tar -czvf linuxdb.tar.gz jay kiran music jay kiran music [root@localhost redhat]# 0 comment 0 FacebookTwitterPinterestEmail Editorial Staff previous post Linux Basics next post Linux Basics You may also like Linux Basics February 24, 2023 Linux Basics February 24, 2023 Linux Basics February 23, 2023 Linux Basics February 23, 2023 Linux December 19, 2022 Leave a Comment Cancel Reply Save my name, email, and website in this browser for the next time I comment.