Saturday, May 22, 2010

Feeding password to sudo over command line

I'm sure all linux users (ubuntu) have had a day when the security features of the OS, just seemed a tad more annoying than ever before. Specially when you have to put your password into sudo for every menial task. Or perhaps all you wanted to do was install a package using apt-get and didn't care to press "Y" in front of every question that followed.

Here's something you can do to minimize user intervention after you press the enter key in order to execute a command. To feed your password to sudo, use the following construct:

user-laptop$ echo <password> | sudo -S apt-get install blogilo

Using the -S switch allows you to feed the password through a pipe using echo over the command line. In order to skip the crazy prompts for apt-get, use the following construct:

user-laptop$ sudo apt-get -y install blogilo

Here's something that combines the two:user-laptop$ echo <password> | sudo -S apt-get -y install blogilo

P.S.:

This is my first post using "Blogilo". Just moved to Kubuntu (KDE4 for ubuntu. Download the kubuntu-kde4-desktop package if you're on v10.04). Loving the new UI and the cool desktop effects. Konsole (the default terminal for KDE, sucks... no transparency!) has still miles to go before i leave gnome-terminal. Empathy and Gnome-terminal are the only GNOME apps that I'm still hung over. The rest is good. Desktop effects is really the area where KDE takes the cake. You can toggle between desktop effects based on your power options too. So if you're running on battery power, you may wanna keep these effects to the minimum, and turn them back on when you're plugged into a power socket. You can have as many desktop workspaces as you want, and toggle between them using a mouse or keyboard. Miss the simplicity of GNOME, but for now, KDE is gonna stay :D !!

Check out the video below, to get a glimpse of KDE has to offer. This is just the tip of the iceberg.



KDE 4.3 desktop effects

1 comments:

  1. You can also add NOPASSWORD directive in your sudoers file, if you dont want sudo to ask password

    ReplyDelete