Forrest logo
back to the 7z tool

7z:tldr:24731

7z: Encrypt an existing archive (including filenames).
$ 7z a ${path-to-encrypted-7z} -p${password} -mhe=on ${path-to-archive-7z}
try on your machine

This command is using the "7z" command-line tool to create an encrypted 7z archive file.

Here is the breakdown of the command:

  • "7z": This is the command to run the 7z tool.
  • "a": This is an argument for the 7z command, specifying that we want to create an archive.
  • "${path-to-encrypted-7z}": This is the path and filename for the output encrypted 7z file. You need to replace "${path-to-encrypted-7z}" with the actual desired file path and name.
  • "-p${password}": This is an argument to set the password for the encrypted 7z file. You need to replace "${password}" with the actual desired password.
  • "-mhe=on": This is an argument to enable the header encryption for the 7z file. This will encrypt file names and other metadata in the archive.
  • "${path-to-archive-7z}": This is the path and filename for the input files that you want to include in the archive. You need to replace "${path-to-archive-7z}" with the actual desired file path and name.

So, by running this command, it will compress and encrypt the files specified by "${path-to-archive-7z}", and create an encrypted 7z archive file at the location specified by "${path-to-encrypted-7z}" with the provided password.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the 7z tool