1

I have added a shell script to my ~/bin folder. When I type the script name normally in the terminal it finds the script just fine. However, when trying to launch the script using the sudo prefix, I get sudo: apt-get4: command not found.

Command that works: apt-get4

Doesn't work: sudo apt-get4 update


Currently the script is owned by the user pi with executable privileges, and I also chmod 777'd.
The script filename is 'apt-get4'.

Any ideas?

1

~/bin is accessible only to the user (here pi), but is not on the path for root user.

If you want to run with sudo you will need to enter the full path /home/pi/bin/apt-get4.

This is not the best way to do things, and is not actually a Pi question.

  • I went ahead and added 'sudo' in front of my command inside the shell script. Sorry if this isn't the right forum, I asked here in case things were different on the pi vs other Linux distros. – moatist Aug 21 '17 at 5:38
  • 1
    @moatist Raspbian is a standard Linux Debian distribution; it differs only in the boot process and in having a few Pi specific commands e.g. gpio to access the hardware. – Milliways Aug 21 '17 at 5:44

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.