I've read a few posts such as Is there a standard place for placing custom Linux scripts? , Where should I put my bash scripts , but I still am getting an error that my script isn't being found in bash.

I've placed my script (Named Wandering_Echo) in /usr/local/Custom_Programs and symlinked it into /bin, /usr/local/bin, and /usr/local/sbin, but when I try running sudo Wandering_Echo, I get this error:

sarah@LesserArk:/usr/local/Custom_Programs$ sudo Wandering_Echo ?
sudo: Wandering_Echo: command not found

Not sure what I'm doing wrong as it is in the super-user bin directory.

Wandering_Echo does some low level filesystem operations using BTRFS, so it needs root to run. Edit 0: Wandering_Echo does run as regular user, just not as super-user from terminal.


sarah@LesserArk:/usr/local/Custom_Programs$ ls -l /usr/local/bin/Wandering_Echo /usr/local/Custom_Programs/Wandering_Echo 
lrwxrwxrwx 1 root root 14 Aug 14 15:22 /usr/local/bin/Wandering_Echo -> Wandering_Echo
-rw-r--r-- 1 root root 96 Aug 14 13:09 /usr/local/Custom_Programs/Wandering_Echo


sarah@LesserArk:~$ sudo bash -c 'echo $PATH'
[sudo] password for sarah: 
  • sudo ./Wandering_Echo or sudo {interpreter/python/perl} Wandering_Echo – Rinzwind Aug 14 at 18:06
  • Please add the output of ls -l /usr/local/bin/Wandering_Echo /usr/local/Custom_Programs/Wandering_Echo and sudo bash -c 'echo $PATH' to your question. – Florian Diesch Aug 14 at 18:10
  • @FlorianDiesch Maybe it's the execute flags? Sorry about the delay, I was running errands. – Sarah Szabo Aug 14 at 19:27

There are two problems:


lrwxrwxrwx 1 root root 14 Aug 14 15:22 /usr/local/bin/Wandering_Echo -> Wandering_Echo

If you access a symlink its target value is taken as a path relative to the symlink's parent folder (or as an absolute path if it starts with /). So this symlink doesn't point to /usr/local/Custom_Programs/Wandering_Echo but to itself, which isn't that useful. Remove it and use

sudo ln -s /usr/local/Custom_Programs/Wandering_Echo /usr/local/bin/Wandering_Echo

to create it properly. Check the other symlinks, too.


-rw-r--r-- 1 root root 96 Aug 14 13:09 /usr/local/Custom_Programs/Wandering_Echo

As you already wrote in the comments the execute flags are missing here. Use

sudo chmod u+x /usr/local/Custom_Programs/Wandering_Echo

to make it executable for root only. Replace u+x with a+x to make it executable for all users.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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