Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




File Compression with gzip

Often it would be nice to make a file smaller - say, to download it faster, or so it takes up less space on your disk. The program to do this is called gzip (GNU zip). Here's how it works:

cd; cp /etc/profile ./mysamplefile
This switches to your home directory and copies an arbitrarily chosen file (/etc/profile) to your current directory, in the process renaming it mysamplefile. This gives you a file to play with when using gzip.

ls -l
Lists the contents of the current directory. Note the size of mysamplefile.

gzip mysamplefile
Compresses mysamplefile.

ls -l
Observe the results of this command: mysamplefile is now called mysamplefile.gz . It's also a good bit smaller.

gunzip mysamplefile.gz; ls -l
This uncompresses the file. Observe that mysamplefile has returned to its original state. Notice that to uncompress, one uses gunzip, not gzip.

rm mysamplefile
Use this command to remove the file, since it was just to practice with.

John Goerzen / Ossama Othman

  Published under the terms of the GNU General Public License Design by Interspire