Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

This question already has an answer here:

I am learning to write shell script from this tutorial on It says -

Most modern Linux distributions encourage a practice in which each user has a specific directory for the programs he/she personally uses. This directory is called bin and is a subdirectory of your home directory.

I've tried this. But I get the following error-

foobar: command not found

Later in that page, it also says that-

On some distributions, most notably Ubuntu, you will need to open a new terminal session before your newly created bin directory will be recognised.

It means that ubuntu does support this feature. But why isn't it working?

I am on Ubuntu 12.04 LTS.

share|improve this question

marked as duplicate by Mateo, Eric Carvalho, Raja, Basharat Sialvi, Thomas Ward Apr 24 '13 at 4:53

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.

Did you copy your foobar script to /bin? – green Apr 23 '13 at 16:21
Also, make sure the script is executable, and called foobar, not – jackweirdy Apr 23 '13 at 16:24
@Hennes Please take a look at this link to learn some basic tricks to format your comments quickly. – green Apr 23 '13 at 16:32
Without the backticks the helpful parser makes the http:// part invisible. Not sure how to work around that without typing it twice. :( – Hennes Apr 23 '13 at 16:40
@Hennes This is the result of your link: What are “$PATH” and “~/bin”? How can I have personal scripts? And it seems to be a duplicated. – Lucio Apr 23 '13 at 21:18

When you log in or start a new shell then some scripts get parsed. Exactly which scripts depend on which shell you use (e.g. ksh, csh, tsch, bash, dash, pinosh, ...) and if it is a log-in shell or not.

If you are using Ubuntu's defaults then it is likely that it will contain this:

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then

In other words, if ~/bin/ already exists, then add it to the search path.
If it does not exists then there is no reason to try to search that location every time. So do not add it.

This means that you will have to create ~/bin/ and then start a new shell, or create it and manually add a path to it.

As to "Most modern Linux distributions encourage". This was already encouraged in 1991 when I got my first unix account on a server running ESIX. Still true today though.

share|improve this answer
That code snippet isn't present in ~/.bashrc or /etc/bash.bashrc by default; is there somewhere else you've found this? – jackweirdy Apr 23 '13 at 17:06
In my Ubuntu 12.10 VM it is in the last four lines of ~/.profile (but not in /root/.profile) – Hennes Apr 23 '13 at 17:14

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