I want to run my custom scripts but every time I need to execute it I have to type bash before the script name. But I want to run it just like we would run other scripts such as ls git sed chmod etc where typing bash prior to the script name is not required.

I haven't found any solution here, but the closest was this Bash Script does nothing

I have created a script named test


echo Hello

But when I type it on terminal it gives no error and prints nothing

user@notebook:~$ test

But it works when I type it with bash

user@notebook:~$ bash test

I have added the file to ~/.local/bin/, given it the permission chmod a+x test and ~/.local/bin is set in my PATH variable.

My stat /bin/bash is

  File: /bin/bash
  Size: 1396520     Blocks: 2728       IO Block: 4096   regular file
Device: 806h/2054d  Inode: 30408799    Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2023-05-07 12:23:17.179593764 +0500
Modify: 2022-01-06 21:23:33.000000000 +0500
Change: 2022-10-08 20:47:19.225627603 +0500
Birth: 2022-10-08 20:47:19.217622335 +0500

My stat /bin is

  File: /bin -> usr/bin
  Size: 7           Blocks: 0          IO Block: 4096   symbolic link
Device: 806h/2054d  Inode: 12          Links: 1
Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2023-05-07 12:22:43.299594371 +0500
Modify: 2022-10-08 20:47:18.020812502 +0500
Change: 2022-10-08 20:47:18.020812502 +0500
Birth: 2022-10-08 20:47:18.020812502 +0500

The output of type -a test is:

test is a shell builtin 
test is /home/saad/.local/bin/test 
test is /usr/bin/test 
test is /bin/test 
  • Is Bash actually installed in /bin/bash? Please include output of stat /bin/bash and stat /bin. Also, which version of Ubuntu are you using? Thanks. May 7 at 12:21
  • i used which bash and it returned /usr/bin/bash. I have corrected that but still there is no change for me. My ubuntu version is Ubuntu 22.04.2 LTS. I have added the stat output in my question.
    – Saad
    May 7 at 12:24
  • Do you perhaps have an alias or shell function that is masking the script? What is the output of type -a myscript? May 7 at 12:31
  • The prompt says that you create your script in your HOME directory: user@notebook:~$ bash myscript What is the output of readlink -f myscript ? May 7 at 12:34
  • 1
    I guess the script is named after its contents: echo ... hence /bin/echo and /usr/bin/echo the external echo command ... Bash also has a builtin echo ... Had you used the actual script-file's name, it would've been a lot easier for you and us :-)
    – Raffa
    May 7 at 13:36

1 Answer 1


This gives away what has really happened:

The output of type -a test is:

test is a shell builtin 
test is /home/saad/.local/bin/test
test is /usr/bin/test
test is /bin/test
  1. Your script has the name test, which is the same as a Builtin Command

  2. NEVER name your scripts exactly the same as internal commands - this will have unwanted consequences.

  3. So you simply need to name your scriptfile something else than test (or any other internal command).

  4. If you want to run your own script instead of a standard application (like ls), you should create an alias with the name and the full path of your script, like:

    alias ls='/home/saad/.local/bin/myscript'
Important note:

The next time you ask a question like this, please include the correct name of your script, and not a placeholder name. Now that you have included the correct name, it's obvious to many of the users here that it was called test, which is the same as an internal command.

  • 1
    Thank you and the others who commented. It was my mistake that I used a place holder which lengthened the time to answer here. I appreciate you guys!
    – Saad
    May 7 at 15:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .