🔺 For cellphones 🔺
How to extract compressed files zip, 7z, rar and tar
Extraction of compressed files using the terminal is rather easy.
Open a terminal with Ctrl+Alt+T and cd into the directory the compressed file is in
cd /home/user/Directory-nameor in your file manager window where the compressed file is, right click and chose ‘Open in Terminal’.
.ZIP
Compress
zip [options] filename.zip file1 file2 folder/- filename: The name of the ZIP file you want to create.
- file1, file2, folder/: The files or folders you want to compress.
- [options]: Replace'[options] with one or more or none of the options below.
Common Options for the ZIP Command
- -r Recursively include files in subdirectories.
- -u Update an existing ZIP file with new files.
- -d Delete specific files from the ZIP archive.
- -e Encrypt the ZIP file with a password.
- -x Exclude specific files from being added.
Extract
In the terminal that’s cd’d into the directory the zip file is located use this command.
unzip filename.zipReplacing “filename’ with the name of your file.
.7z (7 zip)
To extract a 7zip file in the Linux terminal, first ensure you have the ‘p7zip’ package installed.
In a terminal use the following command to install ‘p7zip’ package
In Debian/Ubuntu
sudo apt install p7zip-fullIn Fedora/CentOS/RHEL
sudo yum install p7zip p7zip-pluginsIn Arch Linux
sudo pacman -S p7zipCompress
Open a terminal in the directory the files you want to compress reside.
To compress all the files in the directory, use this command.
$ 7z a filename.7z *To compress specific files in the directory, use this command.
$ 7z a filename.7z file1.txt file2.txtReplace “filename’ with the name you want your 7z file to be.
Extract
Once you have the package installed, cd into the directory the compressed file is in and use the following command.
7z x filename.7zReplacing “filename’ with the name of your file.
.RAR
Compress
To compress an entire directory recursively:
rar a -r filename.rar /path/to/directoryTo compress multiple files into a single RAR file:
rar a filename.rar file1.txt file2.txt file3.txtReplacing “filename’ with the name of your file.
Extract
To extract a rar file in the Linux terminal, first ensure you have the ‘unrar’ package installed.
In a terminal use the following command to install ‘unrar’ package
In Debian/Ubuntu
sudo apt install unrarIn Fedora
sudo dnf install unrarIn RHEL/CentOS
sudo yum install epel-release
sudo yum install unrarIn Arch Linux
sudo pacman -S unrarIn OpenSUSE
sudo zypper install unrarOnce you have the package installed, cd into the directory the compressed file is in and use the following command.
unrar x filename.rarReplacing “filename’ with the name of your file.
.TAR
The basic syntax for the tartar command is:
tar [options] [archive-file] [file/directory...]Common Options
Here are some commonly used options with the tar command:
- -c Create a new archive
- -x Extract files from an existing archive
- -t List the contents of an archive
- -f Specify the name of the archive file
- -v Verbose output (shows details of the process)
- -z Compress the archive using gzip
- -j Compress the archive using bzip2
- -J Compress the archive using xz
Creating a Compressed Archive
To compress files into a tar.gz archive, use the following command:
tar -czvf filename.tar.gz /path/to/directory_or_fileFlags
- -c creates a new archive.
- -z applies gzip compression.
- -v provides verbose output.
- -f specifies the name of the archive.
Example Command
To compress a complete directory , you would run:
tar -czvf filename.tar.gz directory-nameExtract
To extract a tar file in the Linux terminal, use the command,
tar -xvzf filename.tar.gzreplacing ‘filename’ with the name of your tar file.
Flags
- -x: Extract files from the archive.
- -v: Verbose mode, which lists files being extracted.
- -z: check if a string is null
- -f: Specifies the filename of the archive.
Extracting to a Specific Directory
To extract the files to a specific directory, use the -C option followed by the directory path:
tar -xvzf filename.tar -C target_directoryFor example, to extract to a directory named Documents, use:
tar -xvzf filename.tar -C ./DocumentsListing Contents Before Extraction
Before extracting, you may want to list the contents of the .tar file to ensure it contains the files you expect. Use:
tar -tvf filename.tarThis command will display the files in the archive without extracting them.



Watch the Series.

Watch the Series.