sudo echo “something” >> /etc/privilegedFile doesn’t work [duplicate]

Use tee –append or tee -a. echo ‘deb blah … blah’ | sudo tee -a /etc/apt/sources.list Make sure to avoid quotes inside quotes. To avoid printing data back to the console, redirect the output to /dev/null. echo ‘deb blah … blah’ | sudo tee -a /etc/apt/sources.list > /dev/null Remember about the (-a/–append) flag! Just tee … Read more

Getting “Permission Denied” when running pip as root on my Mac

Use a virtual environment: $ virtualenv myenv .. some output .. $ source myenv/bin/activate (myenv) $ pip install what-i-want You only use sudo or elevated permissions when you want to install stuff for the global, system-wide Python installation. It is best to use a virtual environment which isolates packages for you. That way you can … Read more

sudo in php exec()

It sounds like you need to set up passwordless sudo. Try: %admin ALL=(ALL) NOPASSWD: osascript myscript.scpt Also comment out the following line (in /etc/sudoers via visudo), if it is there: Defaults requiretty

How to fix ‘sudo: no tty present and no askpass program specified’ error?

Granting the user to use that command without prompting for password should resolve the problem. First open a shell console and type: sudo visudo Then edit that file to add to the very end: username ALL = NOPASSWD: /fullpath/to/command, /fullpath/to/othercommand eg john ALL = NOPASSWD: /sbin/poweroff, /sbin/start, /sbin/stop will allow user john to sudo poweroff, … Read more

How do I use sudo to redirect output to a location I don’t have permission to write to? [closed]

Your command does not work because the redirection is performed by your shell which does not have the permission to write to /root/test.out. The redirection of the output is not performed by sudo. There are multiple solutions: Run a shell with sudo and give the command to it by using the -c option: sudo sh … Read more