Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have just recently installed Light Table downloading it from the git repository, and followed the instructions on this website to create a desktop launcher.

Now I want to run the program by directly typing in the terminal

LightTable

and not

./opt/LightTable/deploy/LightTable
share|improve this question
5  
@user68186 Adding the containing directory to the PATH environment variable is often not the best way to achieve this, and may sometimes even break the system or create security vulnerabilities. (One must consider any other executables that will be turned into commands from this, as well as where in PATH it's added.) Adding a shell alias, as covered by answers here, is better for anyone who doesn't want to consider such complexities; it is also more narrowly tailored to the specific app in question. Thus this is not a duplicate of that question, though they do overlap a little bit. –  Eliah Kagan Jul 21 at 23:20
    
Related (but not necessarily a duplicate): How do I add a directory to my path? –  Seth Aug 25 at 2:47

5 Answers 5

up vote 10 down vote accepted

This can be crudely accomplished with an alias. You can create a permanent bash alias by adding a single line to your .bashrc file.

In the terminal run nano ~/.bashrc

Add the the following line at the bottom:

alias LightTable='/full/path/opt/LightTable/deploy/LightTable'

notice I added thee full path instead of the . so this will work in any working directory. (Make sure to restart the terminal for the alias to work.)

share|improve this answer

This isn't an elementary question, the best way to do this is to make an alias, Ill use netbeans as an example

Open Terminal Ctrl+Alt+T

nano ~/.bashrc

write this at the bottom of the file:

alias netbeans='/home/john/netbeans-7.0.1/bin/netbeans'

Ctrl + x

Y

Enter

The netbeans word is the command you will use to start the program, you can change it to whatever you need. Inside the quotes is the command you want to run when netbeans alias is called.

In order this command to be active you have to re-open the Terminal

share|improve this answer
    
I cannot vote up due to my low reputation, but thank you for answering, it was very useful –  dapias Jul 21 at 16:40

You can try to copy the executable to /usr/bin if its a simple executable program and doesn't depend on any other file. if it does depend of other files, the best to do is create a shortcut command to the program.

Where you create the alias is by yourself (.bashrc, .profile, etc). However I personally let all my enviroment variables in my .bash_aliases file (you need to create it at first stance).

Create the file .bash_aliases in your HOME folder and edit it anyway you like. Then to create the shortcut, you can do:

alias LightTable='path_to_opt/LightTable/deploy/LightTable'

Save the file and that's it.

ps: you can also put the alias as lighttable and LIGHTTABLE in case forget to uppercase the L or if capslock is active by accident, so you don't have to type the command again.

share|improve this answer
    
I cannot vote up due to my low reputation, but thank you for answering, it was very useful –  dapias Jul 21 at 16:41

I'm not sure why other answerers have not suggested this, but as the OP actually pointed out, prepending to the $PATH variable would have been the way I would have achieved this:

echo 'PATH=/opt/LightTable/deploy:$PATH' >> ~/.bash_profile
source ~/.bash_profile

Then run with:

LightTable
share|improve this answer
    
Note: I would then alias LightTable to lighttable for ease of use: echo 'alias LightTable=lighttable' >> ~/.bash_alias && source ~/.bash_alias. –  MasterRoot24 Jul 22 at 8:02

Better to create a symbolic link than an alias I think. An alias might make substitutions on your command line when you didn't want one; creating a symlink will allow you to run the program as you want:

sudo ln -s full_path_to_opt/LightTable/deploy/LightTable  /usr/local/bin

This will create a shortcut in /usr/local/bin (which should be in your PATH already!) to where LightTable actually is. Note also that you can rename the symlink as well if you don't like the capital letters in "LightTable":

sudo ln -s full_path_to_opt/LightTable/deploy/LightTable  /usr/local/bin/lighttable

Just for reference, if the program is awkwardly designed, i.e. complains about not finding configuration files or libraries or whatever, then another solution that might be more useful is creating a wrapper script. To do this just create a file (wherever you like for the time being) called "LightTable" (or whatever else you like) with this in it:

#!/bin/sh
# Simple script to run LightTable
if ! cd full_path_to_opt/LightTable/deploy/LightTable ; then
    echo "$0: error: LightTable directory not found." >&2
    exit 1
fi
exec ./LightTable

Change the permissions of this file:

chmod 755 <wrapper_script>

and try executing it just to see if it works, and if so then move it to /usr/local/bin:

sudo mv -i <wrapper_script> /usr/local/bin
share|improve this answer
    
What your saying is true, but didn't answer what he wanted. He wanted to execute it by using the name of the file/alias of the file –  Johnn Jul 22 at 13:10
1  
@Johnn: I'm sorry, I don't understand what the difference is. I understand the question as asking for a way to execute the program without having to specify its path. Whether the shell uses an alias or the PATH mechanism makes no difference if you are just asking to execute the program. If you wanted to do something else with the file then using an alias to provide the full path of the file is indeed the best way, but (s)he just wants to run the file. Am I mistaken? –  Zorawar Jul 22 at 15:42
    
No that was my fault, your correct. –  Johnn Jul 22 at 15:56
1  
@Johnn: Ah, well, thanks for the critical eye anyway! –  Zorawar Jul 22 at 16:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.