Linux - Lab 5: File Compression
File Compression
In Lab 5: File Compression, participants typically focus on learning and applying techniques related to compressing and decompressing files in a Linux environment. This lab involves using command-line tools such as tar for creating tarballs (compressed archives) and gzip or bzip2 for compressing individual files. Participants may explore different compression algorithms and options to achieve varying levels of compression and file size reduction. Additionally, the lab may cover the extraction and decompression of archived files. The aim of Linux Lab 5 is to provide hands-on experience in efficiently managing file compression and decompression tasks, allowing participants to optimize storage usage and streamline file transfer processes in a Linux operating system. Successful completion of this lab equips participants with practical skills in utilizing compression tools to enhance file management efficiency in Linux.
Lab:
Data Compression involves 2 steps:
- Archiving
- Compression
Compression using tar and gzip:
cp –r /usr/bin /tmp
#To check disk usage of directory
du –h /tmp/bin
#To create an archive
tar –zcf /root/lallu.tar.gz /tmp/bin
#To list contents of an archive
tar –ztvf /root/lallu.tar.gz
#To extract some content
tar –zxf /root/lallu.tar.gz ‘tmp/bin/hostname’ ‘tmp/bin/ls’
#To extract full content
tar –zxf /root/lallu.tar.gz
Compression using tar and bzip2
#To create an archive
tar –jcf /root/lallu.tar.bz2 /tmp/bin
#To list contents of an archive
tar –jtvf /root/lallu.tar.bz2
#To extract content
tar –jxf /root/lallu.tar.bz2
Compression using tar and xzip
#To create an archive
tar –Jcf /root/lallu.tar.xz /tmp/bin
#To list contents of archive
tar –Jtvf /root/lallu.tar.xz
#To extract content
tar –Jxf /root/lallu.tar.xz