Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an executable file "x" stored in a directory. I want to be able to execute program "x" by typing "x" from anywhere in terminal. Currently I have to be in the programs directory and type "./x" to run the program. How can I fix this?

share|improve this question
I'm pretty sure I just need to set an environment variable up to handle this. I've read tutorials and was still confused so I figured I'd ask here. – Drew Jun 15 '10 at 16:50
Also, it would help if I had an example using the following info. path = '/Desktop/cufflinks/x' executable filename = 'x' – Drew Jun 15 '10 at 16:52
up vote 3 down vote accepted

Within your home directory you should see a file called .profile

Open this file and edit it to add the following

export PATH=$PATH:/full/path/to/executable/folder/

Save the file and restart your terminal window.

now that you have added the folder containing your custom executable to the path you should be able to type "x" and run the command.

WARNING: be careful when changing your path. if you make a typo your system will not be happy

EDIT: if you don't have a .profile file in your home directory bash typically looks for profile information in the following order

  1. ~/.bash_profile
  2. ~/.bash_login
  3. ~/.profile
share|improve this answer
If by home directory you mean '/home' (the home directory located at root), then I can't find the .profile. when I run 'textmate .profile' a blank file appears (supposing it created a new one). Do I need to create the .profile? Thanks for your help! – Drew Jun 15 '10 at 16:55
yes it could be export PATH=$PATH:/home/john/project/bin for example if you have a folder in your home directory called project with the executable in its bin folder. if you don't have a .profile just create a new one it should be picked up if not add it to /etc/profile – gruntled Jun 15 '10 at 17:00
comment by Drew: Thanks to gruntled for the proper syntax/command. I fixed my problem by adding export PATH=$PATH:/full/path/to/executable/folder/ to the last line of my bashrc file (~/etc/bashrc). Restarted terminal and everything is working! – Ivo Flipse Jun 15 '10 at 22:19
@Drew home directory on unix systems is typically /home/username/ or the shortcut ~/ – crasic Aug 11 '11 at 5:31

Your Answer


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.