Table of Contents
1. Prepare the compressed package and Shell script
2. Merge self-extracting files
3. Set permissions on self-extracting files
4. Execute the self-extracting file
./my_self_extracting_file
Home Computer Tutorials Computer Knowledge Shell makes Linux self-extracting files

Shell makes Linux self-extracting files

Feb 19, 2024 pm 05:20 PM
document Unzip shell shell script

Shell 制作Linux自解压文件

In Linux systems, sometimes it is necessary to package programs or files into self-extracting files for easy dissemination and installation. This article outlines the basic methods and steps for using shell scripts to create Linux self-extracting files.

1. Prepare the compressed package and Shell script

First, prepare a compressed package containing the programs or files that need to be distributed, and then write a Shell script to perform the decompression and installation steps.

It is assumed here that there is a compressed package file named my_program.tar.gz and a Shell script file named install_script.sh.

2. Merge self-extracting files

Next, use the following command to merge the Shell script file and the compressed package file into a self-extracting file:

cat install_script.shmy_self_extracting_file
Copy after login

This will create a self-extracting file named my_self_extracting_file, which contains the Shell script file and the compressed package file.

3. Set permissions on self-extracting files

Make sure the self-extracting file has executable permissions. Set permissions using the following command:

chmod +x my_self_extracting_file
Copy after login

This will make the self-extracting file executable.

4. Execute the self-extracting file

Now, you can execute the self-extracting file and it will automatically extract and install the program. Use the following command:

./my_self_extracting_file

After execution, the self-extracting file will automatically execute the commands in the Shell script for decompression and installation.

This is a basic example that can be modified and adjusted to suit your needs. In this way, you can more easily create Linux self-extracting files to facilitate distribution and installation of programs or files.

In Linux, you can use a variety of tools to create self-extracting files, one of the commonly used tools is shar. Shar can package multiple files into a self-extracting file. Users only need to run this file to automatically decompress and execute the contents.

To use shar to create self-extracting files, you first need to ensure that shar is installed in your Linux distribution. If it is not installed, you can install it through your package manager. For example, on Debian or Ubuntu, shar can be installed using the following command:

sudo apt-get install sharutils
Copy after login

After the installation is complete, you can use the shar command to package multiple files into a self-extracting file. For example:

shar -my_archive.sh
Copy after login

This will create a self-extracting file named my_archive.sh, which contains three files: file1, file2 and file3. Users only need to run this file and the contents will be automatically decompressed and executed.

In addition to shar, there are other tools that can be used to create self-extracting files, such as using Shell scripts and tar commands. These tools can be selected and used according to needs.

The above is the detailed content of Shell makes Linux self-extracting files. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to transfer files from Quark Cloud Disk to Baidu Cloud Disk? How to transfer files from Quark Cloud Disk to Baidu Cloud Disk? Mar 14, 2024 pm 02:07 PM

Quark Netdisk and Baidu Netdisk are currently the most commonly used Netdisk software for storing files. If you want to save the files in Quark Netdisk to Baidu Netdisk, how do you do it? In this issue, the editor has compiled the tutorial steps for transferring files from Quark Network Disk computer to Baidu Network Disk. Let’s take a look at how to operate it. How to save Quark network disk files to Baidu network disk? To transfer files from Quark Network Disk to Baidu Network Disk, you first need to download the required files from Quark Network Disk, then select the target folder in the Baidu Network Disk client and open it. Then, drag and drop the files downloaded from Quark Cloud Disk into the folder opened by the Baidu Cloud Disk client, or use the upload function to add the files to Baidu Cloud Disk. Make sure to check whether the file was successfully transferred in Baidu Cloud Disk after the upload is completed. That's it

What to do if the 0x80004005 error code appears. The editor will teach you how to solve the 0x80004005 error code. What to do if the 0x80004005 error code appears. The editor will teach you how to solve the 0x80004005 error code. Mar 21, 2024 pm 09:17 PM

When deleting or decompressing a folder on your computer, sometimes a prompt dialog box "Error 0x80004005: Unspecified Error" will pop up. How should you solve this situation? There are actually many reasons why the error code 0x80004005 is prompted, but most of them are caused by viruses. We can re-register the dll to solve the problem. Below, the editor will explain to you the experience of handling the 0x80004005 error code. Some users are prompted with error code 0X80004005 when using their computers. The 0x80004005 error is mainly caused by the computer not correctly registering certain dynamic link library files, or by a firewall that does not allow HTTPS connections between the computer and the Internet. So how about

How to execute .sh file in Linux system? How to execute .sh file in Linux system? Mar 14, 2024 pm 06:42 PM

How to execute .sh file in Linux system? In Linux systems, a .sh file is a file called a Shell script, which is used to execute a series of commands. Executing .sh files is a very common operation. This article will introduce how to execute .sh files in Linux systems and provide specific code examples. Method 1: Use an absolute path to execute a .sh file. To execute a .sh file in a Linux system, you can use an absolute path to specify the location of the file. The following are the specific steps: Open the terminal

What is hiberfil.sys file? Can hiberfil.sys be deleted? What is hiberfil.sys file? Can hiberfil.sys be deleted? Mar 15, 2024 am 09:49 AM

Recently, many netizens have asked the editor, what is the file hiberfil.sys? Can hiberfil.sys take up a lot of C drive space and be deleted? The editor can tell you that the hiberfil.sys file can be deleted. Let’s take a look at the details below. hiberfil.sys is a hidden file in the Windows system and also a system hibernation file. It is usually stored in the root directory of the C drive, and its size is equivalent to the size of the system's installed memory. This file is used when the computer is hibernated and contains the memory data of the current system so that it can be quickly restored to the previous state during recovery. Since its size is equal to the memory capacity, it may take up a larger amount of hard drive space. hiber

What should I do if I can't find the decompression option when I right-click on the rar file? What should I do if I can't find the decompression option when I right-click on the rar file? Mar 13, 2024 pm 07:07 PM

How to decompress rar files downloaded from the Internet? Under normal circumstances, you can just right-click and select Extract. However, some users right-click and find that they cannot find the decompression option. What is going on? In fact, it is caused by everyone not making relevant settings for the winrar software. You just need to make settings. The specific steps are as follows: 1. First, we open "winrar" on the computer. 2. Select "Options" in the toolbar and click "Settings". 3. Then select the "Integration" option above, and click "Context Menu Item" after entering. 4. At this time

Different uses of slashes and backslashes in file paths Different uses of slashes and backslashes in file paths Feb 26, 2024 pm 04:36 PM

A file path is a string used by the operating system to identify and locate a file or folder. In file paths, there are two common symbols separating paths, namely forward slash (/) and backslash (). These two symbols have different uses and meanings in different operating systems. The forward slash (/) is a commonly used path separator in Unix and Linux systems. On these systems, file paths start from the root directory (/) and are separated by forward slashes between each directory. For example, the path /home/user/Docume

How to quickly delete the line at the end of a file in Linux How to quickly delete the line at the end of a file in Linux Mar 01, 2024 pm 09:36 PM

When processing files under Linux systems, it is sometimes necessary to delete lines at the end of the file. This operation is very common in practical applications and can be achieved through some simple commands. This article will introduce the steps to quickly delete the line at the end of the file in Linux system, and provide specific code examples. Step 1: Check the last line of the file. Before performing the deletion operation, you first need to confirm which line is the last line of the file. You can use the tail command to view the last line of the file. The specific command is as follows: tail-n1filena

Windows PowerShell Scripting Tutorial for Beginners Windows PowerShell Scripting Tutorial for Beginners Mar 13, 2024 pm 10:55 PM

We've designed this Windows PowerShell scripting tutorial for beginners, whether you're a tech enthusiast or a professional looking to improve your scripting skills. If you have no prior knowledge of PowerShell scripting, this article will start with the basics and be tailored for you. We'll help you master the installation steps for a PowerShell environment and walk you through the main concepts and features of PowerShell scripts. If you're ready to learn more about PowerShell scripting, let's embark on this exciting learning journey together! What is WindowsPowerShell? PowerShell is a hybrid command system developed by Microsoft

See all articles