The easiest way to run an INSTALL.sh script in a Linux terminal window

Did you download Linux software that came with an install.sh file? Install.sh is a simple text-based shell script that makes it easy to install software. To use an install.sh script, you'll first need to make it executable using chmod +x install.sh. Then, you can execute the script in a terminal with the command ./install.sh or sudo ./install.sh. This wikiHow guide will walk you through executing an install.sh file from the Linux command line using Ubuntu, Debian, and any other version of Linux.

Things You Should Know

  • To make install.sh file executable, use the command chmod +x install.sh.
  • To execute the script, run the command ./install.sh.
  • Depending on permissions, you may need to start each command with sudo to gain superuser (root) access.

Steps

  1. 1
    Open a Terminal window. On most Linux desktop environments, you can open a Terminal by pressing Ctrl + Alt + T.
    • Before installing software, make sure to check the README or INSTALL file that came in your download for specific instructions and installation options.
  2. 2
    Use cd to enter the folder that contains the install.sh script. For example, if install.sh is in your Downloads folder, type cd ~/Downloads and press Enter to enter that directory.
    • If the file you downloaded is compressed into a TGZ or TAR.GZ archive, be sure to unpack the files first.
    • You can extract a TGZ or TAR.GZ file using the command tar -xzvf filename.tgz.
    • To make sure you’re in the right directory, type ls -a and press Enter. You should see your install.sh file, as well as all other files in the directory.
    Advertisement
  3. 3
    Make the install.sh file executable. The trick to getting the install.sh script to run is to change its permissions. To do this, type chmod +x install.sh and press Enter.
    • If you're unable to change the permissions, you'll need root access. Instead, run sudo chmod +x install.sh and press Enter.
    • If you don’t see an error, you’ll know the install script is now executable.
  4. 4
    Execute the install.sh script. To do this with root access, type sudo ./install.sh and press Enter.
    • You can also use the command sudo bash install.sh or sudo sh install.sh to run the script.
    • If you're just installing the software in your own home directory and don't need root permissions, you can use omit sudo and use ./install.sh instead.
    • Depending on the script and app you're installing, you may be prompted to complete additional steps to install the software.
  5. 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

Nicole Levine, MFA
Written by:
wikiHow Technology Writer
This article was co-authored by wikiHow staff writer, Nicole Levine, MFA. Nicole Levine is a Technology Writer and Editor for wikiHow. She has more than 20 years of experience creating technical documentation and leading support teams at major web hosting and software companies. Nicole also holds an MFA in Creative Writing from Portland State University and teaches composition, fiction-writing, and zine-making at various institutions. This article has been viewed 428,674 times.
How helpful is this?
Co-authors: 4
Updated: February 6, 2023
Views: 428,674
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