Difference between revisions of "Sudo: menjalankan command di script"
Jump to navigation
Jump to search
Onnowpurbo (talk | contribs) |
Onnowpurbo (talk | contribs) |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 7: | Line 7: | ||
Atau jika hanya salah satu command saja, bisa | Atau jika hanya salah satu command saja, bisa | ||
| − | sudo -u username | + | sudo -u username "perintah" |
Atau kalau mau memaksa, bisa | Atau kalau mau memaksa, bisa | ||
| Line 13: | Line 13: | ||
exec sudo su -c "perintah" | exec sudo su -c "perintah" | ||
| + | |||
| + | ===Jika di tanya password=== | ||
| + | |||
| + | Tambahkan script | ||
| + | |||
| + | echo passwordsudonya | sudo -S 'script.sh' | ||
==Referensi== | ==Referensi== | ||
* https://askubuntu.com/questions/425754/how-do-i-run-a-sudo-command-inside-a-script | * https://askubuntu.com/questions/425754/how-do-i-run-a-sudo-command-inside-a-script | ||
| + | |||
| + | |||
| + | ==Pranala Menarik== | ||
| + | |||
| + | * [[ssh]] | ||
Latest revision as of 10:45, 17 December 2018
sumber: https://askubuntu.com/questions/425754/how-do-i-run-a-sudo-command-inside-a-script
Cara yang normal tambahkan sudo sebelum menjalankan script
sudo myscript.sh
Atau jika hanya salah satu command saja, bisa
sudo -u username "perintah"
Atau kalau mau memaksa, bisa
exec sudo su -c "perintah"
Jika di tanya password
Tambahkan script
echo passwordsudonya | sudo -S 'script.sh'
Referensi