How to Extract / Uncompress 7z Files on Ubuntu

I’d like to import a database dump file, but it’s compressed in 7zip format (7z). So I need to extract that 7z file using 7za. 7za is included in p7zip package.

First we need to verify whether we have 7za installed or not.

whereis 7za

If you see something like:

7za: /usr/bin/7za /usr/share/man/man1/7za.1.gz

It means 7za is already installed on your system. But if you see nothing like above, then you must install p7zip package.

How to install p7zip to extract 7z files on Ubuntu

sudo apt-get install p7zip

How to Extract / Uncompress 7z files on Ubuntu

7za e my_source_file.7z

It means we will extract / uncompress the my_source_file.7z.

How to Create a 7z files on Ubuntu

7za a my_target_file.7z my_source_directory/

It means all files and sub directories of my_source_directory/ will be added to the my_target_file.7z.