I have script that opens several terminal windows running iftop
for observing various ports activities.
Each terminal that opens asks me for the sudo password ... which is a bit of a pain considering that there are 5 terminals overall.
So my question is, how do I type in sudo password once and have all the windows run using that permission rather than typing it in per window?
#!/bin/bash
TITLE="${USER}@${HOSTNAME}"' iftop (h=help, L=lin/log scales, t=line display mode, T=line totals, p=port display)'
gnome-terminal --title "$TITLE" -e 'sh -c "sudo iftop -P -f \"port 22\""' --hide-menubar --zoom=0.85
TITLE="${USER}@${HOSTNAME}"' iftop (h=help, L=lin/log scales, t=line display mode, T=line totals, p=port display)'
gnome-terminal --title "$TITLE" -e 'sh -c "sudo iftop -P -f \"port 33 or port 44\""' --hide-menubar --zoom=0.85
TITLE="${USER}@${HOSTNAME}"' iftop (h=help, L=lin/log scales, t=line display mode, T=line totals, p=port display)'
gnome-terminal --title "$TITLE" -e 'sh -c "sudo iftop -P -f \"(port 55) or (port 66)\""' --hide-menubar --zoom=0.85
I did try running the entire script as sudo
and that results in all the terminals being opened also being a sudo terminal. What I need is a regular terminal running the sudo iftop
instead.