In the next article I will show you the main Linux commands for 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.
Gz files
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
Bz2 files
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
To unzip:
- bzip2 -d file.bz2
Tar.gz files
To compress a file or directory to this extension we will use the following line:
- tar -czfv archive.tar.gz files
To unzip:
- tar -xzvf file.tar.gz
To view the content of a file in tar.gz format:
- tar -tzf file.tar.gz
Tar.bz2 files
To compress to this format we will use:
- tar -c files | bzip2> file.tar.bz2
To unzip:
- bzip2 -dc file.tar.bz2 | tar -xv
- bzip2 -dc file.tar.bz2 | tar -t
Zip files
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
Rar files
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
West:
- 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
Good article thanks I like the terminal
Very interesting article. I always wondered how some packages were unzipped. Thanks and best regards.
Hello
The command to compress in tar gz is tar -czvf (not tar -czfv) otherwise it fails.