Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have written a bash script from which i execute it from the root. I want to execute a particular command in a user account rather than root account.So how to execute that command in a user account and not in root account.For example i want to execute this command

echo 'user_pref("toolkit.networkmanager.disable", true);' >> ~/.mozilla/firefox/*.default/prefs.js` 

in a user account say karthick how to execute it?

share|improve this question
    
In the case of appending a file, you could just append it as root, and the file will still be owned by the user. Hence, you don't really need either sudo or su in this specific case. –  Egil Apr 24 '11 at 10:25

2 Answers 2

up vote 1 down vote accepted
sudo -u karthick 'echo \'user_pref("toolkit.networkmanager.disable", true);\' >> ~/.mozilla/firefox/*.default/prefs.js`'

Most likely your problem can be solved more elegantly by some other means. Perhaps if you described that we could help solve the larger problem.

share|improve this answer
su karthick -c "echo \'user_pref(\"toolkit.networkmanager.disable\", true);\' >> ~/.mozilla/firefox/*.default/prefs.js"
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.