Multiple sudo command with a pipe

Asked by arky

If have a command where you use sudo twice with a pipe, sudo should prompt only once. Is this a bug?

$ sudo <command one> | sudo <command two>
[sudo] password for arky: [sudo] password for arky:

~~~
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu jaunty (development branch)
Release: 9.04
Codename: jaunty

$ apt-cache policy sudo
sudo:
  Installed: 1.6.9p17-1ubuntu3
  Candidate: 1.6.9p17-1ubuntu3
  Version table:
 *** 1.6.9p17-1ubuntu3 0
        500 http://in.archive.ubuntu.com jaunty/main Packages
        100 /var/lib/dpkg/status

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu sudo Edit question
Assignee:
No assignee Edit question
Solved by:
Brent124578
Solved:
Last query:
Last reply:
Revision history for this message
Simone Cianfriglia (crimer) said :
#1

It's normal, sudo caches password for 15 minutes in the default configuration

Revision history for this message
arky (arky) said :
#2

My question was why sudo prompts like this. See it prints two prompts right next to one other.
[sudo] password for arky: [sudo] password for arky:

Revision history for this message
peter (peter-neuweiler) said :
#3

Maybe this helps.

sudo allows to execute only one command in a line. If you're going to use sudo for more commands in the same line, enter sudo su. Now you will be able to execute more than one command in a line.

Hope it helps.
Peter

Revision history for this message
arky (arky) said :
#5

Thanks Brent124578, that solved my question.