Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux custom executable globally available

Tags:

linux

ubuntu

I downloaded the Google App Engine as a zip format, unzipped it to /usr/local/google_engine

Now I need to run a python script from that folder all the time. How do I make it available no matter where my path is? ie: when i'm in /usr/something/ i can execute the script by just calling script.py?

Can I do this without aliasing or without using bash scripts?

like image 490
WindowsMaker Avatar asked Apr 19 '12 19:04

WindowsMaker


People also ask

How can I make a program executable from everywhere?

To make the program executable from anywhere for all users, we can add it to the global profile settings in /etc/profile. We should note that /etc/profile and ~/. bash_profile are specific to the Bash shell. Other shells will likely use different locations.


2 Answers

There are two ways to do this. As Kal mentioned above you can add the folder to the path variable by adding

export PATH=/usr/local/google_app_engine/bin:$PATH1  

to your .bashrc. Alternatively, if the command is just one script you can move or copy it to /usr/bin. This will make it accessible as a command from anywhere.

If you want to create a command to do this without moving script.py then you can create a bash file that calls it with a fixed path then put that in /usr/bin

like image 34
Vogon Jeltz Avatar answered Sep 30 '22 07:09

Vogon Jeltz


Edit your .bashrc to add the desired directory on the PATH environmental variable.

export PATH=/usr/local/google_app_engine/bin:$PATH 

then, either start new terminal or do,

source ~/.bashrc 

Now try to run the script from anywhere.

Another way you can do it without even touching the .bashrc would be to create a symlink by doing something like,

sudo ln -s /usr/local/google_app_engine/bin/script.py /usr/bin/script.py  
like image 135
Kalpak Gadre Avatar answered Sep 30 '22 06:09

Kalpak Gadre