0

I have downloaded a program that does not need installation through the web;

How can i create a command for the terminal to open that specific command:

Example: open terminal, type unity-control-center to open system-settings

2 Answers2

2

I assume your question goes like that: "How do I execute a downloaded program, which is not installed in the systems default executables directory?"

If you only want to use the program for a short period of time, simply mark it as executable with

chmod +x path/to/my-program

Now, you can run it with

path/to/my-program

Should your working directory be the one the program is inside, it doesn't suffice to write program. Instead, you have to do

./my-program

If you're gonna keep it, though, the most practicable thing to do is to install it manually by placing it in /usr/local/bin, the directory intended for executables not managed by the package manager.

Move or copy the executable there using

sudo mv /path/to/my-program /usr/local/bin/ # or sudo cp...

Also ensure the file is marked as executable, which is normally not true when it was downloaded from somewhere:

sudo chmod +x /usr/local/bin/my-program

Should the program come with any special libraries or resource files, things may become a bit more complicated. If you want to comply to standards, you should move those files to /usr/local/share/my-program/, else just move them to /usr/local/bin, too (and hope noone ever sees that except for you ☺ )

Now, your program may not find those files on its own. If this is true, you can create a launcher script, e.g. /usr/bin/local/start-my-program or whatever you like:

#!/bin/bash
env PATH=$PATH:/usr/local/share/my-program/ /usr/local/bin/my-program

Also, make this one executable again with

sudo chmod +x /usr/local/bin/start-my-program
s3lph
  • 14,314
  • 11
  • 59
  • 82
0

Couple of points :

1) That fine/binary has to be placed somewhere in your path. echo $PATH to know what folders are available. Preferably you'd place it in /usr/bin or create bin folder in your home folder, and add that folder to your $PATH

2) The binary/executable must have permissions -rwxr-xr-x when you list it with ls -l mybinary. Use chmod +x mybinary to achieve that that.

3) Once binary is in folder that is part of your $PATH and is executable, there is a myriad of ways to run it. One, you can type it in terminal just like you wrote in your question, another way is to create alias to it; there's also an option to create a custom shortcut that will open the terminal and run that command. For that open System Settings -> Keyboard -> shortcuts tab -> Custom -> click + sign, and name it whatever you want; for command , write gnome-terminal -e /path/to/your/binary or xterm -hold -e /path/to/your/binary

Sergiy Kolodyazhnyy
  • 105,154
  • 20
  • 279
  • 497