Getting Around Linux: How to Execute || Initiate || Run ‘install.sh’

I’ve been messing around with a few programs on Gnome lately and a few of them require the user to execute a file called ‘install.sh’ in the command prompt in order to initialize the installation process. In order to do this you just type:

sudo sh install.sh

- or just -

sh install.sh

Pretty straight forward right? Well… not always. Typically installing a downloaded package requires you to extract your files into a directory. There are two notes that Linux users assume everyone knows:

  • You have full read, write, and execution permissions to the directory and files you are extracting.
  • You actually know which directories and files have these permissions.

At first this sounds like a no brainer, but to the ex-Windows user who had administrative access to all permissions by default, this represents a new experience. When installing your own programs that are not from ‘apt-get’ or from the Ubuntu Package Manager, I suggest users download new packages and install new programs in subdirectories located under the ‘/home/user_name/’ directories.  As for myself I have directory for new packages called ‘/home/alex/downloaded_packages’

You can view privileges for all your new files and directory by navigating to the location of your extraction and typing:

ls -l

Which typically results in a directory listing that looks like this:

total 6100
-rwxr-xr-x 1 alex 725 Jul 10 15:07 stuff.txt
drwxr-xr-x 2 alex 512 Jun 13 16:19 dev
....

The entries that start with a d are directories. The next 3 letters are permissions for the owner. The owner is specified by the name in the third grouping of characters from the left.

Even after downloading the new package, the default permissions assigned to the extracted files and directories may not have sufficient privileges to install the program after running ‘sh install.sh’, resulting in a permissions error. To remedy this, you need to give all extracted files and directories execution privileges. You can do this by going to the location of the extracted files and typing the following:

find . -type d -exec chmod 700 '{}' ';'
find . -type f -exec chmod 700 '{}' ';'

The first command sets all directories in the current directory permissions to read, write, and execute, while the second command does the same for files. This will give the owner of the files sufficient permissions to run the ‘install.sh’ command.

If the above doesn’t work, you can try giving everyone full rights to the files in the current directory.  A warning though, this should only be done to files that are temporary and only to files that you trust. A lot of security holes in Windows is attributed to the fact that full rights are given to all files during execution. To do the aforementioned type:

find . -type d -exec chmod 777 '{}' ';'
find . -type f -exec chmod 777 '{}' ';'

Hopefully, this should give you the ability to run those ‘install.sh’ files you get. If you’d like more information on the above consult the following:

Leave a Reply