append a line to text file in script
Hi I am modifying a script and I need a command to add a line to the end of the /etc/modules file. It currently reads like this
Quote:
Quote:
can someone help? |
First do a backup of the original file somewhere, for example
Code:
cp -p /etc/modules /etc/modules.bck Code:
echo ath_pci >> /etc/modules |
When I type sudo echo ath_pci >> /etc/modules I keep getting the message bash: /etc/modules: permission denied
I thought if I used sudo it should give me permission to do this |
I had thought that sudo was for enabling a user to run certain SW--but not to bypass permissions. (I never use it, so I'm not sure.)
Why not just "su" to get root powers? Especially when developing a script, you want to test things the way the script will run. |
Using redirection with sudo should take some care. Your command line executes the echo command with root privileges then tries to store the output in /etc/modules as regular user. From the sudo man page there is an useful example:
Quote:
Code:
sudo sh -c "echo ath_pci >> /etc/modules" |
All times are GMT -5. The time now is 11:54 PM. |