3

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?

1
  • 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, 2011 at 10:25

2 Answers 2

2
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.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .