File Archiving and Compressing - RHCSA
Why file archiving and compressing is important?
- Creating Backups
- Transferring data across network is much easier.
What is an Archiving?
Archiving is the process of collecting files or directories into one location.We use tar command for it.
tar stands for Tape Archiving.
Options:
- c - Create an archive
- t - List the content of the archive
- x - Extend the archive
- v - Verbose (print the file names when they are archiving or compressing)
- f - File name
Examples:
#mkdir data1
#mkdir data2
#mkdir data3
#tar cvf data-archive.tar data1 data2 data3
data1, data2, data3 files are archived. Archived file name is data-archived.tar
We cannot create same name archive files because they are overwriting without given any feedback. Hence use ls -l command.
#tar cvf <archive file path> <file paths which need to archive>
If we want to archive /var/log file in /root/log-archive.tar file. Use following command.
#tar cvf /root/log-archive.tar /var/log
c- create an archive | v- verbose | f- file name
Compressing
Compressing is a mechanism to reduce the size of a file. There are two methods of compressing.- gzip - extension .gz or .tgz
- bzip - extension .bz2 or .tbz2
If we want to zip /usr/local file,
- tar czvf local-zip.tgz /usr/local --> gzip
- tar cjvf local-zip.tbz2 /usr/local --> bzip
Archiving and Compressing
If we want to archive and compress /usr/local,- tar czvf /root/arzip.tar.tgz /usr/local --> gzip
- tar cjvf /root/arzip.tar.tbz /usr/local --> bzip
Extracting
First identify what is the extension of compressed folder. (.tar.tgz or .tar.tbz)#mkdir unzip
#cd unzip
#tar xzf /root/arzip.tar.tgz
x- extract | z- bzip | f- file name
Comments
Post a Comment
Thank you for your comment