Linux provides several easy ways to install new programs, such as through the Ubuntu Software Center and the Synaptic Package Manager. Still, some applications must still be installed from the command prompt. This wikiHow teaches you how to install an application from an INSTALL.sh file at the command line.

Steps

  1. 1
    Download the software you wish to install. The necessary files will usually be compressed into a .tar, .tgz, or .zip file.
  2. 2
    Extract the ".tar" or ".zip" (if needed). If the software you downloaded is in an archive format like ".tar", ".tgz", or ".zip" file, you will need to extract it to get to the .sh file. If the script is already in a ".sh" file format, you can skip this step. Use one of the following methods to extract the archive file:
    • Right-click the downloaded archive, and then select Extract Here (the exact text may vary by Linux version).
    • If you are using the terminal, use the command "cd ~/path" to navigate to the location of the archive file. Replace "path" with the folder path of the file (i.e. "cd ~/Downloads").
    • To extract a ".tar", or ".tar.gz" file using the terminal, use the command "tar -xvf filename.tar" and press "Enter". Replace "filename" with the actual name of the file (i.e "tar -xvf jdk-14.0.2_linux-x64_bin.tar.gz")[1]
    • To unpack a ".zip" file from the terminal, use the command "unzip filename.zip" and press "Enter". Replace "filename" with the name of the zip file (i.e. "unzip Minecraft.zip").
    Advertisement
  3. 3
    Find one which folder the ".sh" file is in. To do this, you'll need to double-click the extracted folder and search the folders contained to see which folder contains the install.sh.
  4. 4
    Open a terminal window. The terminal has an icon that resembles a black screen with a text cursor on it. Click it in the dock or Applications menu to open the terminal.
    • A quick way to do this in most window managers is to press "Ctr + Alt + T" on the keyboard.
  5. 5
    Navigate to the path of the extracted folder. Type "cd ~/" followed by the path to the ".sh" file and press "Enter". ″ Use the a foward-slash (/) to differentiate between different folders. For example, if the file is is your downloads folder, you would type something like "cd ~/Downloads/jdk-14.0.2_linux-x64_bin/bin" and press enter.
    • To make sure you’re in the right folder, type "ls -a" at the command prompt and press "Enter". You should see a list of the same files and folders.
  6. 6
    Type chmod +x install.sh and press Enter. If the installer is called something other than ″install.sh,″ type the actual filename instead. This makes the installer file executable. You won’t see any confirmation message from this command.
    • As long as you don’t see an error, you’ll know the script is now executable.
    • You can also do this outside the terminal. The process may be different depending on your Linux distribution. To do this in Ubuntu, right-click the ".sh" file and click Properties. Click the Permissions tab and check the box that says "Allow executing file as program".
  7. 7
    Type bash install.sh and press Enter. If the file name is named something other than ″install.sh″, replace the "install.sh" with the actual file name. For example, to install Netbeans, you would type "bash netbeans-8.2-linux.sh" and press "Enter".
    • Other commands you can use include "sh install.sh" or "./install.sh". If the file name is different than "install.sh", use the actual name of the ".sh" file instead. Then press "Enter". Use any of these commands and press "Enter".[2]
  8. 8
    Enter the root user password and press Enter. This starts the installation of your application.
  9. 9
    Follow the on-screen instructions to complete the installation. Depending on the app, you may have to enter additional information to complete the install.
    • To uninstall a piece of software using the terminal, type the command "dpkg --list" to display a list of installed programs on your Linux system. Locate the program you want to uninstall and type the command "sudo apt-get --purge remove [program name]" and press "Enter". Enter the root user password and press "Enter". Then follow any instructions needed to remove the program.<ref>
  10. Advertisement

Community Q&A

  • Question
    How to run a Linux program from terminal
    Community Answer
    Community Answer
    Enter these commands into the terminal: cd /location of file/. For example, /home/username/Documents./name_of_file.extension. Replace these with the name of the file/program and the extension (commonly .desktop in Linux or .exe (executable) or .sh (script). Make sure the file/program is marked as executable in its properties.
  • Question
    I typed: chmod +x install.sh but the output is chmod: cannot access 'install.sh': No such file or directory.
    Pingu
    Pingu
    Top Answerer
    This means that there is no install.sh file. Linux is case-sensitive, so if you type the file name as install.sh, it won't find a file that is named, for example, INSTALL.sh. Also check for typos, like typing isntall.sh instead of install.sh. Try typing ls to list all files in the current directory. If the install.sh file is not in the current directory, you need to change into the directory with that file using the cd command.
  • Question
    I want my (.sh) files to be executable by 1 word like "test" without commanding "./test.sh | bash test.sh". How to do that?
    Pingu
    Pingu
    Top Answerer
    If that's a program that someone else wrote, you can usually run "sudo make install" to install it, and then it will be possible to just type the program name. If it is a script that you wrote yourself, do the following: Add the line "#!/bin/bash" (without the quotation marks) to the beginning of the script file. Rename the file to not have ".sh" at the end, for example "test.sh" to just "test". Finally, move your file to the "/usr/bin" directory. Then, you can just type the word (in this example, "test") to execute the script. Also, when working from the Linux bash shell, you don't need to type the " | bash test.sh" part, you can just write "./test.sh".
Advertisement

About This Article

Travis Boylls
Written by:
wikiHow Technology Writer
This article was co-authored by wikiHow staff writer, Travis Boylls. Travis Boylls is a Technology Writer and Editor for wikiHow. Travis has experience writing technology-related articles, providing software customer service, and in graphic design. He specializes in Windows, macOS, Android, iOS, and Linux platforms. He studied graphic design at Pikes Peak Community College. This article has been viewed 398,820 times.
How helpful is this?
Co-authors: 4
Updated: September 7, 2020
Views: 398,820
Categories: Linux
Article SummaryX

1. Download and extract the package.
2. Open a terminal window.
3. Go to the folder that contains the "install.sh" file.
4. Use "chmod +x" to make "install.sh" executable.
5. Type "bash install.sh" and press Enter.
6. Enter the root password and follow the on-screen instructions.

Did this summary help you?
Advertisement