CHMOD: Operation not permitted
-
Hi!
I would like to add a power button to my raspberry pi 3b+, I have installed retropie 4.5.1 and I'm following this tutorial:
https://www.makeuseof.com/tag/add-power-button-raspberry-pi/
But when I type this line on the terminal:
chmod a+x shutdown-press-simple.pyI get the messege:
chmod: changing permissions of 'shutdown-press-simple.py': Operation not permittedDoes anyone have a fix for this?
-
@GrixSilva said in CHMOD: Operation not permitted:
Does anyone have a fix for this?
Since you used
sudo
to start the editor, the file was created with owner=root
. TL;DR - usesudo
to run the commandsudo chmod ....
EDIT: btw, the tutorial has a small error - in the
/etc/rc.local
file you should add the full path to the script. -
@mitu But to be true the www instruction is awfull ;)
- would change rc.local to /opt/configs/all/autstart.sh
- Use annother GPIO, to make powerdown and restart work ;)
- @mitu is always right ;)
@GrixSilva You can read this instructions to have more fun with just one button. With this setup you can also switch ON the Pie ;)
https://howchoo.com/g/mwnlytk3zmm/how-to-add-a-power-button-to-your-raspberry-pi -
@mitu
Thanks for the help, the chmod command has been accepted, but this way of adding the power button didn't work, maybe I add the wrong rc.local path.
So I decided to follow the advice of @cyperghost and follow this guide:
https://howchoo.com/g/mwnlytk3zmm/how-to-add-a-power-button-to-your-raspberry-pi
It seems to be a more explicit guide. -
@cyperghost
I followed all the instructions, I just changed:GPIO.setmode(GPIO.BCM)
GPIO.setup(3, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.wait_for_edge(3, GPIO.FALLING)to:
GPIO.setmode(GPIO.BCM)
GPIO.setup(21, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.wait_for_edge(21, GPIO.FALLING)because I was already using gpio3 pin for the fan.
This time the switch works, but only turns off the raspbery py, it doesn't turn it on.
Do you know what it could be?
-
@GrixSilva said in CHMOD: Operation not permitted:
Do you know what it could be?
Make sure you're using the same 2 GPIO pins (5 and 6) for your button as described in the video.
-
@GrixSilva As I wrote in my last posting, the guide you've found is awful - full of command mistakes.
-
@mitu
In the video they use pin 5 and 6 (GPIO 3 and GROUND) to install the button, but in my setup I have a fan install on pins 4 and 6 (5V and GROUND), Thats why I changed this code from the instructions:GPIO.setmode(GPIO.BCM)
GPIO.setup(3, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.wait_for_edge(3, GPIO.FALLING)to:
GPIO.setmode(GPIO.BCM)
GPIO.setup(21, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.wait_for_edge(21, GPIO.FALLING)To connect my button to pins 39 and 40 (GND and GPIO 21), the problem is my PI only turn off, it doesn' turn on.
I must say I don't understand much about the GPIO pins , maybe the connections aren't compatible with the system, I dont know. xD
If you have any sugestions, I would like to know!
Thak you anyways! :) -
@mitu
I SOLVED THE PROBLEM!!!My problem was my confusion! XD
With my fan installed, I was using pin pin 4 and 6, I forgotte I don't need to use the same GND pin, so I connected my button to pin 5 and pin 39 (GND) now it works!Althouth, I noticed If I disconnect the power supply and then connect it again, my pi will turn ON automatically, ignoring the button. The button only works if the PI is always being powered.
Is there a workaround?If I don't disconnect the power supply, my fan doesn't stop. Or maybe there is a way to turn OFF my Fan once I turn OFF my PI.
-
@GrixSilva said in CHMOD: Operation not permitted:
Is there a workaround?
No not with a simple button.
You can use the Powerblock device or a dedicated case from Retroflag to make this work.
-
@cyperghost
Thank for the advice, I'll see what I can do! :)
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.