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 Answer 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.Glorious G– Glorious G2017年08月21日 05:38:35 +00:00Commented 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.Milliways– Milliways2017年08月21日 05:44:31 +00:00Commented Aug 21, 2017 at 5:44