Installing and running 7zip from Mac terminal
You can download unarchiver from Apple store and use the unar command to use 7zip or use homebrew as follows. I am assuming you have homebrew installed.
$ brew update $ brew install p7zip
These command update brew and install p7zip. To zip a file
$ 7z a myfile.7z mydirectory
$ 7z x myfile.7z