Today, I tried to use this command on my raspberry Pi:
sox -t mp3 /home/pi/test.mp3 -t wav - | /home/pi/PiFmRds/src/pi_fm_rds -audio -
But I got this error message :
Failed to open /dev/mem: Permission denied.
Terminating: cleanly deactivated the DMA engine and killed the carrier.
sudo: ./sox : command not found
I've tried to place "sudo" before the command but I got the same error.
How can I resolve this please ? (and sorry if I did a mistake, I started playing with my raspberry today and this is also my first question on this website)
Thanks in advance !
Putting sudo in front of sox will not help you since I am pretty sure the error message "Failed to open /dev/mem" comes from pi_fm_rds. And that is still started without sudo.
You are actually executing two commands. sox is the first, and pi_fm_rds the second. You are sending the output of the first command to the second (via the pipe |).
To call pi_fm_rds with root access you can choose one of these three options:
Call pi_fm_rds with sudo
sox -t mp3 /home/pi/test.mp3 -t wav - | sudo /home/pi/PiFmRds/src/pi_fm_rds -audio -
Or add your user to the kmem group (which allows access to /dev/mem) - requires logout/reboot.
sudo usermod -a -G kmem userName
or make the program setuid root - or setgid kmem
chown root:root /home/pi/PiFmRds/src/pi_fm_rds
chmod u+s /home/pi/PiFmRds/src/pi_fm_rds
Related
I am facing a very strange error with my Laravel application on the production server (Linux). Whenever the users of my application login for the first time in morning, they get a permission denied error which read something like
file_put_contents(/var/www/html/PROJECT/storage/framework/cache/data/0c/e5/0ce52dca12715a327eb4c1b4bff36293ea67c719): Failed to open stream: No such file or directory
To overcome this, the first thing I have to do in the morning is to give permission to the entire project by
sudo chmod -R 777 PROJECT
And then it runs just fine.
This is slowly getting very annoying as it is happening every morning. Why are the permissions getting revoked automatically and is there a permanent solution for this?
Please help me and thank you all in advance
I think your application run some command also. That's why your storage permission is overrated by system user. (by which user cron execute).
The thing is, storage directory should have write access to both system user and webserver(apache/nginx)
BTW, Symfony framework has some nice solution for this kind of situation which also can be application in Laravel Application.
Please look at this:
https://symfony.com/doc/current/setup/file_permissions.html
In your case, this command would be like:
HTTPDUSER=$(ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1)
sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:$(whoami):rwX /var/www/html/PROJECT/storage
sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:$(whoami):rwX /var/www/html/PROJECT/storage
You can also achieve above solution if you know know what is your webserver user.
sudo chown -R "$local_user":"$webserver_user" "/var/www/html/PROJECT/storage"
sudo chmod -R 0777 "/var/www/html/PROJECT/storage"
If my opinion, setfacl is better solution if you have setfacl installed in your server.
You can check if your webserver has enough permission to the directory instead of giving 777 to the project as this is your production environment which is not at all recommendable.
Also try php artisan cache:clear
I was trying to install wireshark when I accidentally had to restart my computer. Now I am stucked in a infinite login loop in Ubuntu. I tried to do something from the bash but every time I try to run a sudo command, as sudo su it gets:
-bash: /usr/lib/command-not-found: /usr/non/python3: bad interpreter: permission denied.
I tried to change the permission to that but it does not work.
EDIT:
i solved by entering in recovery mode as root user and sudo chmod 777 /usr/lib/command-not-found and even sudo chmod 777 /usr/bin/python3. I tried everything possible, and i dont even know why it worked.
Try this
sudo dpkg -i python2.7-miminal*.deb
sudo dpkg -i python2.7*.deb
I ran into the same problem when I have added export $PATH="~/bin" as last line in ~/.bash_profile.
I solved it by removing the line after entering into tty2 command line using "ctrl + alt + F3" and all commands like "ls, cd, nano" where available as "/bin/ls, /bin/cd, /bin/nano".
Using command "/bin/nano ~/.bash_profile" I changed the file content and now it's working normally.
The following works fine and I get the edgecnt out from 'ls' program on my ubuntu 14.04 system..
$ ../../../pin.sh -t obj-intel64/edgcnt.so -- /bin/ls
but while using it on my node application I got permission denied error:
$ ../../../pin.sh -t obj-intel64/edgcnt.so -- /home/samira/Documents/benchmarks/lets-chat/
/home/samira/Documents/benchmarks/lets-chat/ : Permission denied
I searched all the web about that but I haven't found any solution. I tried runing both node application and pin tool as root but it didn't solve the problem. Also used the pid to run:
s# ../../../pin -pid 14191 -t obj-intel64/edgcnt.so -o myout.log
E: Could not attach to process 14191: need execute and read access to /proc/14191/exe
I tried to change the permission of /proc/ folder but the operation was not permitted even for the root.
Any idea?
while using pin on your node application,got permition denied,have you change the user group?
as a root,"root#server:~# echo 0 > /proc/sys/kernel/yama/ptrace_scope"
may help your question.
"s# ../../../pin -pid 14191 -t obj-intel64/edgcnt.so -o myout.log
E: Could not attach to process 14191: need execute and read access to /proc/14191/exe" I think this means the pid you want to trace doesn't exsist.
I recently installed LAMP on my Ubuntu 14.04 laptop. But I didn't have full/root access to the files var/www and etc/apache2/sites-enabled/000-default.conf so I did some research to change permissions and admissions to the directory, using this command in the terminal:
sudo chown -R username:group directory
It worked perfectly. But now I can't do any sudo commands in the terminal. I wanted to restart the apache server but here is what it showed me:
sudo: /etc/sudoers is owned by uid 1000, should be 0
sudo: no valid sudoers sources found, quitting
sudo: impossible d'initialiser le greffon de règles
(my computer is in french btw).
What I want to know is how to set it back to sudo. I hope I explained myself good enough. If you need additional info that I didn't state please tell me. I will add it. Thnx.
Seems like you chown'd /etc/sudoers.
Try:
sudo chown root:root /etc/sudoers
Then if you want read/write privileges, see which group the folder /var/www belongs to (probably www-data)
To add yourself to the www-data group, try:
sudo useradd -a -G www-data yourUserName
Also, as a side note; be careful of recursive commands!!! If you're not sure what a command does, test it on a single file before making it recursive. For example:
DO NOT RUN THIS CODE, I DON'T INCLUDE SUDO ON PURPOSE SO YOU DONT HOSE EVERYTHING
rm -r /
Will delete everything inside / (a lot of stuff!)
I'd like to automate root scripting actions on my remote Fedora server via SSH without having to install the scripts on the server. To do this, I'm trying to use Bash's inline script notation. This works fine in Ubuntu, but I'm getting strange errors on Fedora.
e.g.
#!/bin/bash
ssh -t myuser#myserver <<EOI
su -
ls /root
exit
exit
EOI
This gives me the output:
standard in must be a tty
ls: cannot open directory /root: Permission denied
I've also tried:
#!/bin/bash
ssh -t myuser#myserver <<EOI
sudo ls /root
exit
EOI
but this gives me:
sudo: no tty present and no askpass program specified
If I manually ssh in and run these commands, they run fine since myuser is in the sudoers file. I've Googled these errors and have tried some fixes, but nothing's worked so far. How do I resolve this?
Looks like you're being prompted for the password but have no way to enter it. Here's a few things that should help.
Try an extra -t option: ssh -tt myuser#myserver <<EOI
Also this is a handy trick to log on as root without the root password being enabled: sudo su -
As a last resort you can setup your user to sudo without a password using visudo. You might see some comments like these to help you out:
# Uncomment to allow members of group sudo to not need a password
# (Note that later entries override this, so you might need to move
# it further down)
# %sudo ALL=NOPASSWD: ALL