In the next article I will show you the main Linux commands to compress and decompress files in the different most used formats.
Surely some other user or follower of the blog, thinks that using the terminal having programs or ways to do it graphically or assisted, is a real backwardness, but as Knowledge does not take place, and I like to know what I am doing and check different ways of doing things, here are the main commands to compress and decompress files in Linux based in Debian.
To compress a file in gz format we will use the following command:
- gzip -9 file
Where file is the name of the file to compress
To unzip it we will use this:
- gzip -d file.gz
This compressed extension is only capable of compressing / decompressing individual files, so don't try it with folders.
To compress we will use:
- bzip file
- bzip2 -d file.bz2
To compress a file or directory to this extension we will use the following line:
- tar -czfv archive.tar.gz files
- tar -xzvf file.tar.gz
To view the content of a file in tar.gz format:
- tar -tzf file.tar.gz
To compress to this format we will use:
- tar -c files | bzip2> file.tar.bz2
- bzip2 -dc file.tar.bz2 | tar -xv
- bzip2 -dc file.tar.bz2 | tar -t
This is one of the most widespread formats in use, to compress a file to this extension from the terminal we will use the following command line:
- zip archive.zip files
- unzip file.zip
- unzip -v file.zip
This is the most generalized and used other format or extension, to compress a file or directory to this format we will use:
- rar -a archive.rar files
- rar -x file.rar
- rar -l file.rar
- rar -v file.rar
As you can see, it is not so difficult to use the terminal to do some little things from time to time, and thus while we learn, we keep the gray matter in shape.
More information - Some useful keyboard shortcuts for Ubuntu