- 7-Zip command to create and extract a password-protected ZIP file on Windows? [closed]
- 4 Answers 4
- How to password protect gzip files on the command line?
- 7 Answers 7
- 7z Command Tutorial With Examples To Compress And Extract Files In Linux
- Syntax
- 7z Commands
- Switches
- Compress Files and Folders
- Add Files To The Archive
- Delete Files From Archive
- Extract Files From The Archive/Compressed File
- List Contents of Archive
- 10 7zip (File Archive) Command Examples in Linux
- How to Install 7zip in Linux
- Install 7zip on Debian, Ubuntu or Linux Mint
- Install 7zip on Fedora or CentOS/RHEL
- Learn 7zip Command Examples in Linux
- If You Appreciate What We Do Here On TecMint, You Should Consider:
7-Zip command to create and extract a password-protected ZIP file on Windows? [closed]
Want to improve this question? Update the question so it’s on-topic for Stack Overflow.
Closed 17 days ago .
The community reviewed whether to reopen this question 17 days ago and left it closed:
Original close reason(s) were not resolved
On Mac/Linux to zip/unzip password protected zip files, I use: Zip:
What are the equivalent command on Windows on the command line (assuming that 7zip has been installed)?
I have been doing research and found that it is not possible to password encrypt using the Java zip4j library. Also Windows does not have a zip command prompt like Mac/Linux
4 Answers 4
Then provide the SECRET password
Note: If the password contains spaces or special characters, then enclose it with single quotes
General Syntax:
Check your 7-Zip dir. Depending on the release you have, 7z may be replaced with 7za in the syntax.
Parameters:
- -p encrypt and prompt for PW.
- -pPUT_PASSWORD_HERE (this replaces -p) if you want to preset the PW with no prompt.
- -mhe=on to hide file structure, otherwise file structure and names will be visible by default.
Eg. This will prompt for a PW and hide file structures:
Eg. No prompt, visible file structure:
And so on. If you leave target blank, 7z will assume * in current directory and it will recurs directories by default.
To fully script-automate:
Create:
Unzip:
(Depending, you might need to: Set Path=C:\Program Files\7-Zip;%Path% )
I’m maybe a little bit late but I’m currently trying to develop a program which can brute force a password protected zip archive. First I tried all commands I found in the internet to extract it through cmd. But it never worked. Every time I tried it, the cmd output said, that the key was wrong but it was right. I think they just disenabled this function in a current version.
What I’ve done to Solve the problem was to download an older 7zip version(4.?) and to use this for extracting through cmd.
This is the command: «C:/Program Files (86)/old7-zip/7z.exe» x -pKey «C:/YOURE_ZIP_PATH»
The first value(«C:/Program Files (86)/old7-zip/7z.exe») has to be the path where you have installed the old 7zip to. The x is for extract and the -p For you’re password. Make sure you put your password without any spaces behind the -p! The last value is your zip archive to extract. The destination where the zip is extracted to will be the current path of cmd. You can change it with: cd YOURE_PATH
Now I let execute this command through java with my password trys. Then I check the error output stream of cmd and if it is null-> then the password is right!
Источник
How to password protect gzip files on the command line?
I want to create some tar.gz (and possibly tar.bz2) files, using the tar command on Ubuntu 10.04.
I want to password protect the file.
What is the command to do this (I have Googled, but found nothing that shows how to create and extract compressed files using a password).
Anyone knows how to do this?
7 Answers 7
you have to apply the unix-philosophy to this task: one tool for each task.
tarring and compression is a job for tar and gzip or bzip2 , crypto is a job for either gpg or openssl :
Encrypt
Decrypt
Or using gpg
the openssl-variant uses symetric encryption, you would have to tell the receiving party about the used ‘password’ (aka ‘the key’). the gpg-variant uses a combination of symetric and asymetric encryption, you use the key of the receiving party (which means that you do not have to tell any password involved to anyone) to create a session key and crypt the content with that key.
if you go the zip (or 7z) route: essentially that is the same as the openssl-variant, you have to tell the receiving party about the password.
If your intent is to just password protect files, then use the hand zip utility through command line
-e asks the zip utility to encrypt the files mentioned in
Here’s a few ways to do this. One thing to note is that if you’re going to use separate compression and encryption tools you should always compress before encryption, since encrypted data is essentially non-compressible.
These examples compress and encrypt a file called clear_text .
gpg will compress the input file before encryption by default, -c means to use symmetric encryption with a password. The output file will be clear_text.gpg . One benefit of using gpg is that is uses standard OpenPGP formats, so any encryption software that supports OpenPGP will be able to decrypt it.
The -z option compresses. By default this outputs a file called clear_text.gz.nc .
bcrypt compresses before encrypting by default, the -r option is so that the input file isn’t deleted in the process. The output file is called clear_text.bfe by default.
Using gzip and aespipe
aespipe is what it sounds like, a program that takes input on stdin and outputs aes encrypted data on stdout. It doesn’t support compression, so you can pipe the input through gzip first. Since the output goes to stdout you’ll have to redirect it to a file with a name of your own choosing. Probably not the most effective way to do what you’re asking but aespipe is a versatile tool so I thought it was worth mentioning.
Источник
7z Command Tutorial With Examples To Compress And Extract Files In Linux
7zip is a popular tool and compression format. 7zip supports a wide range of platforms and operations systems like Windows, Linux, BSD, macOS, etc.
Syntax
We will use following syntax for 7z command.
First before starting using the 7z command we can get usage and help information by using -h option. We can see that different options like adding file to archive, benchmark, delete files from archive etc. listed with the -h option output.
Alternatively, we can list usage and help information without providing any option to the 7z command like below.
7z Commands
While using 7z there is two-component as we can see in the syntax. One of them is commands. Commands are used to specify the operations like:
- a : Add files to archive
- b : Benchmark
- d : Delete files from archive
- e : Extract files from archive (without using directory names)
- h : Calculate hash values for files
- i : Show information about supported formats
- l : List contents of archive
- rn : Rename files in archive
- t : Test integrity of archive
- u : Update files to archive
- x : eXtract files with full paths
Switches
Switches are used to specify some minor options like create SFX archive, compress shared files, set output log level. Here are some of them
- — : Stop switches parsing
- -ai[r[-|0]] <@listfile|!wildcard>: Include archives
- -ax[r[-|0]] <@listfile|!wildcard>: eXclude archives
- – ao : set Overwrite mode
- -an : disable archive_name field
Compress Files and Folders
7z can compress files and folders. We will use a command to create a new archive. The new archive file name will be mybackup.7z and we will put files named a.out , body.txt and folder cups . Here the
Here while starting 7z applications show some information about the 7z application like build number, version, developer. And then provided files and folders are scanned and the scan result is printed like 56 folders, 1550 files, and a total 142 MB. After compression is completed new archive size is printed as 96 MB.
Add Files To The Archive
In previous example we have created the archive file. Some time we need to add new files to the existing archive file. In this situations we will use same a option to add files.
In this operation mybackup.7z archive file already exists. Some information about the file is printed like path, compression type, size, etc. Then a new file is added to the existing archive or compressed file named mybackup.7z .
Delete Files From Archive
Another useful operation is removing one or more files from an existing archive file. We will use d command with the file we want to delete. In this example, we want to remove the file named fruits.txt from the archive file mybackups.7z .
Extract Files From The Archive/Compressed File
We can extract all files from an archive or compressed file by using x command or option. We will also provide the archive or compressed file. In this example, we will extract the mybackups.7z .
As we can see from the screenshot there are some existing files which will be overwritten. There question whether we want to overwrite, skip, rename, etc. We answer this as Always. After extraction, some statistical information like total folder count, file count size, compressed size is printed.
List Contents of Archive
We can also list files of an archive with l command. We will list all files of mybackup.7z archive.
In the output, we can see that files and folders are listed. While listing information like date, time, attributes, size, and name are provided.
Источник
10 7zip (File Archive) Command Examples in Linux
7-Zip is a free open source, cross-platform, powerful, and fully-featured file archiver with a high compression ratio, for Windows. It has a powerful command line version that has been ported to Linux/POSIX systems.
It has a high compression ratio in 7z format with LZMA and LZMA2 compression, supports many other archive formats such as XZ, BZIP2, GZIP, TAR, ZIP and WIM for both packing and unpacking; AR, RAR, MBR, EXT, NTFS, FAT, GPT, HFS, ISO, RPM, LZMA, UEFI, Z, and many others for extracting only.
It provides strong AES-256 encryption in 7z and ZIP formats, offers a compression ratio that of 2-10 % for ZIP and GZIP formats (much better than those offered by PKZip and WinZip). It also comes with self-extracting capability for 7z format and it’s localized in up-to 87 languages.
How to Install 7zip in Linux
The port of 7zip on Linux systems is called p7zip, this package comes pre-installed on many mainstream Linux distributions. You need to install the p7zip-full package to get the 7z, 7za, and 7zr CLI utilities on your system, as follows.
Install 7zip on Debian, Ubuntu or Linux Mint
Debian-based Linux distributions comes with three software packages related to 7zip and they are p7zip, p7zip-full and p7zip-rar. It is suggested to install p7zip-full package, which supports many archive formats.
Install 7zip on Fedora or CentOS/RHEL
Red Hat-based Linux distributions comes with two packages related to 7zip and they are p7zip and p7zip-plugins. It is suggested to install both packages.
To install these two packages, you need to enable EPEL repository on CentOS/RHEL distributions. On Fedora, no need to setup additional repository.
Once the 7zip package installed, you can move further to learn some useful 7zip command examples to pack or unpack various types of archives in the following section.
Learn 7zip Command Examples in Linux
1. To create an .7z archive file, use «a» option. The supported archive formats for creation are 7z, XZ, GZIP, TAR, ZIP and BZIP2. If the given archive file exists already, it will “add” the files to an existing archive, instead of overwriting it.
Create 7z Archive File in Linux
2. To extract an .7z archive file, use «e» option, which will extract the archive in the present working directory.
Extract 7z Archive File in Linux
3. To select an archive format, use -t (format name) option, which will allows you to select the archive format such as zip, gzip, bzip2 or tar (the default is 7z):
Create 7z Zip File in Linux
4. To see a list of files in an archive, use «l» (list) function, which will displays the type of archive format, method used, files in the archive among other information as shown.
List 7z File Information
5. To test the integrity of an archive file, use «t» (test) function as shown.
Check 7z File Integrity
6. To backup a directory, you should use the 7za utility which preserves owner/group of a file, unlike 7z, the -si option enables reading of files from stdin.
7. To restore a backup, use -so option, which will sends output to stdout.
8. To set a compression level, use the -mx option as shown.
9. To update an existing archive file or remove file(s) from an archive file, use «u» and «d» options, respectively.
10. To set a password to an archive file, use -p
For more information refer to the 7z man page, or go to the 7zip Homepage: https://www.7-zip.org/.
That’s all for now! In this article, we have explained 10 7zip (File Archive) command examples in Linux. Use the feedback form below to ask any questions or share your thoughts with us.
If You Appreciate What We Do Here On TecMint, You Should Consider:
TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
We are thankful for your never ending support.
Источник