Create an archive of the current directory:
7z a filename.7z
Create an archive of a specific directory:
7z a filename.7z /path-to-dir
Extract a 7z archive in the current directory with full path:
7z x filename.7z
Extract a 7z archive in the current directory without directory names:
7z e filename.7z
You should not have a “-” before a or x. It will not work, a will “Add files to archive” and x will extract an archive with full path.
If you have 7za binary, you can use it as well. In CentOS 7, 7z binary is available only after installing p7zip-plugins.
rpm -qf `which 7za` p7zip-16.02-2.el7.x86_64 rpm -qf `which 7z` p7zip-plugins-16.02-2.el7.x86_64
Whereas in Mac, brew install p7zip installs 7z, 7za and 7zr.