Link to this post 12 May 11

Hi, I am new.

I have a simple question.

On Ubuntu, I made a script:


if [ "$(id -u)" = "0" ]; then
echo "superuser"

echo "no"

I called the file "boo".

When I run "boo" as a regular user it says "no". But when I sudo su it, it says "boo" is not a command. So, how do I make it output "superuser".

Hope this make sense.

Link to this post 12 May 11

After you run sudo su your system switches you to the root user and places you in the root home directory. Most likely you launched sudo su when in your chosen directory, but attempted to just call the script name while in the root home directory.

Link to this post 13 May 11

So, how do I go back to my home directory.

On the command prompt is says I am at:


When I "ls" in that directory I see all my files and also "boo".
But when I type "boo" in the command prompt I still get:

boo: command not found

I am stuck, think I am missing something very simple.

Link to this post 13 May 11

If you want to stay in root, just type cd /home/<username>/

If you want to be as user, type exit <enter> first, then cd /home/<username>/

Link to this post 13 May 11

It sounds like Ubuntu is placing the current directory ( $PWD) in the PATH thus you can call the program named "boo" that is in the current directory.

whenever you switch to root the PATH variable must be different.

Try with


Link to this post 13 May 11

Thank you.

The "./boo" worked. But I thought "./" was implied.

I thought by default "./boo" = "boo".

Now, I can move on to the next section. Guess I will use "./" when I am a superuser mode.

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Linux Training / Board