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
#!/bin/bash
echo Hello
But when I type it on terminal it gives no error and prints nothing
user@notebook:~$ test
user@notebook:~$
But it works when I type it with bash
user@notebook:~$ bash test
Hello
user@notebook:~$
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