How to create self-extracting archives with shar in Linux
It's annoying, even tiring, to explain to someone how to unzip after you send them an archive. If so then you will definitely love shar in Linux.
It's annoying, even tiring, to explain to someone how to unzip after you send them an archive. If so then you will definitely love shar in Linux.
With shar, you can 'bundle' multiple files together. If you send it to someone, they just need to make sure it is executable and run to extract it. No need for complex commands or instructions during the process.
Let's see how you can use shar to group files through the following article!
Install shar
Shar is not included in most Linux distributions by default, so you will have to install it first in order to create Shar file archives automatically extracted. However, you won't find it in Software Center or via apt. Instead, you will have to install larger sharutils packages that contain shar. To do that, activate Terminal and use the command:
sudo apt install sharutils
Shar is a command line tool and works on multiple files at once, putting them into a single archive. Therefore, for convenience and ease of use, create a temporary directory and move or copy all the files you want to put into the shar archive to that temporary directory.
With the Terminal still active, use the cd
command to move the file into the newly created directory.
Group files
To create a shar archive, run the following command:
shar ./* > ./archive-filename.shar
Change archive-filename to the preferred file name.
Feel free to dig deeper to understand how you can use your files.
- Of course, shar is the program.
- ./* is the input, and in this particular case, it means all the files in the directory.
- > separates the input and the output of the command. The program understands it as follows: Take all the input on the left of the> and combine it into a single file identified on the right of the>.
- ./archive-filename.shar is the path and name of the output file. You can change it to whatever you want.
This process is quite fast and usually does not take more than a few seconds (depending on PC performance).
Group filesOnce you've created the archive, you can share your new files with others. Although they will also need sharutils installed to automatically extract operations, as you will see in the next step, things will be simpler than dealing with regular repositories.
Extract shar archive
When the other person receives the shar repository, all they need to do is make it workable, then run it.
Assuming the other person has sharutils installed, they can extract the archive using the following commands:
chmod +x archive.shar ./archive.shar
The files contained therein are extracted right next to, in the same directory.
Extract shar archiveYou should read it
- How to create EXE archive with Winrar
- How to automatically delete Zip files after extracting on Mac
- How to enable / disable the Archive Apps feature in Windows 10
- 4 ways to fix the error extracting ZIP files 0x80010135 in Windows 11/10
- How to Archive Folders
- How to Unrar Files in Linux
- How to review old data on a Web site using Archive.org (Wayback Machine)
- How to Archive in Outlook 2007
- How to Protect a Zip File with a Password on PC or Mac
- Archive Extractor - Free online decompression tool with over 70 different file formats
- Set a password for the RAR archive
- Windows 11 native RAR support 'benchmark' results compared to WinRAR and other compression applications
Maybe you are interested
Hackers attacked hundreds of universities to gain access to library data Top website, application of Vietnamese Pinyin dictionary Iranian Siemens continued to sabotage the nuclear plant Spy virus attacks the Iranian Government Duqu computer virus attacked Iranian business The United States and Israel are behind the Stuxnet worm, according to the New York Times