Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 used to know a way to run my shell scripts just by typing there name as long as there were in my home folder or desktop. I hate having to type ./ I would like to be able to type just How can I fix my terminal to do this?

I'm using GNOME Terminal and Ubuntu 9.04.

share|improve this question
up vote 19 down vote accepted

It's a bad idea to put the current directory into your path. Move your scripts that you want to frequently run into ~/bin and then add ~/bin to your path.

To do this, add:

export PATH=$PATH:~/bin

to ~/.bash_profile.

share|improve this answer
Thank you! Why is this so hard to find on google? – Lucas McCoy Jul 11 '09 at 3:05
+1 for "It's a bad idea.."! – Arie K Jul 11 '09 at 3:10
@Lucas: It's no longer hard to find on Google :) – MikeyB Jul 11 '09 at 3:18
@MikeyB: SF saves the day again! – Lucas McCoy Jul 13 '09 at 21:39

You can add . to the path, but as MikeyB says, it is a bad idea.

The reason it is a dangerous thing to do is that if a malicious bit of software with the same name as an executable you are running exists in the current directory, that will be run instead.

share|improve this answer

I put my shell scripts in /usr/local/bin, seems the best place for them? it's usually empty. Make them executable and forget the .sh extension, and you can just call them plainly.

That's on Ubuntu server.

share|improve this answer
/usr/local/bin is the right place for scripts that are meant for all users. ~/bin is for scripts for that user. Of course it doesn't matter if you're the only user... – sleske Jul 23 '09 at 9:03

To answer the question that was asked, add your home directory and the desktop to the path.

share|improve this answer
+1, and the lesson is: be careful what you ask for :-) – DutchUncle Feb 24 '11 at 17:38

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.