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.

This question already has an answer here:

System utilities such as ls don't need to have the full path typed before executing them. However, to execute Netbeans, I have to type /home/chris/netbeans-7.0.1/bin/netbeans. How can I make it so that I only have to type netbeans?

share|improve this question

marked as duplicate by muru, Charles Green, Elder Geek, Eric Carvalho, Andrea Corbellini Dec 9 at 18:45

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3 Answers 3

up vote 5 down vote accepted

An easy way is to place a link in /usr/local/bin:

sudo ln -s -T /home/chris/netbeans-7.0.1/bin/netbeans /usr/local/bin/netbeans

after that you can execute netbeans with:

netbeans &
share|improve this answer
    
What does the -T do? man says it treats the link name as a normal file - but as opposed to what? –  Casebash Feb 16 '12 at 7:21
    
@Casebash: in case the path /usr/local/bin/netbeans already exists and is a directory, without -T would create a the link inside the given directory with the same base name as the linked file. With the -T in such a situation it should give an error. –  enzotib Feb 16 '12 at 8:02
1  
Yes, if /usr/local/bin/netbeans already exists you should give the link another name. then you have to invoke the other name as command for starting netbeans. –  Michael K Feb 16 '12 at 8:12
    
I'd put the symlink in ~/bin instead; since the executable is located in the homedir. mkdir -p ~/bin && ln -s ~/netbeans-7.0.1/bin/netbeans ~/bin. If ~/bin exists, it will be added to your PATH. This happens during login though, so if ~/bin did not already exist, you need to log out and back in for the new command to be available. –  geirha Feb 20 '12 at 6:19

You can add an alias

Open Terminal Ctrl+Alt+T

nano ~/.bashrc

write this at the bottom of the file:

alias netbeans='/home/chris/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
  1. go to the program directory.
  2. open the terminal using ctrl+alt+T.
  3. Drag and drop the program file to the terminal windows.
  4. Hit enter on the terminal windows.
share|improve this answer
    
or simply create a dektop shortcut :D –  chathurawidanage Feb 16 '12 at 7:14
    
If someone is trying to avoid typing in the path to his program, is going to the program directory in the file manager, and then doing all the things you describe, going to be better? –  Chan-Ho Suh Feb 16 '12 at 7:18
    
that's why I told to create a desktop shortcut... desktop shortcut does the same thing in terminal. Then he can take the advantage of seeing program errors in terminal without typing the full path!! –  chathurawidanage Feb 16 '12 at 7:21

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