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.
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).

Once 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.

You should read it
- 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
May be interested
- 5 best open source backup utilities for Linuxthere are so many backup utilities available in the market, confusing you to choose the best one out of the many options. this article will help you choose the free backup utility that is best suited for linux and suits your needs.
- How to set the JAVA_HOME path in Debian 10in this article, we will learn how to install java jdk on the debian operating system and then set the java_home and path variables.
- How to install Microsoft Teams on Linuxif your job requires using a linux distribution such as ubuntu, debian or red hat, you no longer need to use a windows 10 device to connect with colleagues, as microsoft teams is now available on linux. .
- How to install dictionaries in Linux Terminala locally stored dictionary utility can really be useful when no other dictionary is available. there are many options in the linux software world. among these, there is an option that runs fairly 'smoothly' from the system terminal, called sdcv.
- How to change the cursor size on the Debian 10 desktopdebian allows you to change the cursor size via the settings utility. you can access the settings utility through the application launcher search.
- How to spell check in Linux Terminallinux also has a command line spell checker utility in terminal. the utility is called aspell and is installed by default on ubuntu. this is how you can use aspell to check spelling in a terminal.