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?

asked Aug 21, 2017 at 5:16

1 Answer 1

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.

answered Aug 21, 2017 at 5:29
2
  • 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. Commented Aug 21, 2017 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. Commented Aug 21, 2017 at 5:44

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.