affordableCebu
Classified Ads
Tips & Guides
Login
Register
Search
Ask Question
Post a Free Ad
Home
»
Questions
»
Computers
[
Ask a new question
]
sudo with password in one command line?
sudo with password in one command line?
On busy days, I'd like to run
Asked by:
Guest
| Views: 288
Total answers/comments:
5
Comments display order:
By default
New comments first
Old comments first
Guest
[
Entry
]
"Yes, use the -S switch which reads the password from STDIN:
$echo <password> | sudo -S <command>
So for your case it would look like this:
$./configure && make && echo <password> | sudo -S make install && halt
of course, replace <password> with your password."
Guest
[
Entry
]
"You can do this too:
sudo -S <<< ""password"" command"
Guest
[
Entry
]
"You could replace your command line with this:
$sudo su
$./configure && make && make install && halt
You will be prompted for your password immediately, then the rest of the commands will run as superuser."
Guest
[
Entry
]
"Note, I've found that method doesn't work on an older version of sudo, specifically ""Sudo version 1.6.7p5"":
$ echo ""<your_password>"" | sudo -S -k whoami
Where as this method does work on older and new versions sudo:
$ echo ""<your_password>"" | sudo -S -v
$ sudo whoami"
Guest
[
Entry
]
"If you want to take more care, you could make a script, change the permissions of the file so only root can read and edit and then just run it.
Example:
1) Create a file:
gedit ~/.easy.install
2) Paste this and save:
./configure && make && echo <password> | sudo -S make install && halt
3) Make it executable:
sudo chmod +x ~/.easy.install
4) Change the permissions of the file so only root can read and edit it:
sudo chmod 700 ~/.easy.install
5) Run:
~/.easy.install
Enjoy ;-)"