Not sure if this is the right way to do this, but it sure works. Be sure to understand that the backtick (`) is different than the literal quote (')
kill the process ID of iftop
Code: Select all
sudo kill `ps aux | grep "sudo iftop" | awk '{print $2}'`
BTW, Perhaps you want to launch your gnome terminal in a background process. Consider adding the ampersand
Code: Select all
gnome-terminal --command="sudo iftop -i eth0 -p" &
Edit2: I should mention that it might be possible to configure your user to have permissions access to the block device of your ethernet. thus this problem of having a user starting a sudo process which does not terminate might be solved.
Edit3: I've not thoughoughly tested these properties of making new gnome-terminal windows, it seems that even when i type a user command (one which i could be able to terminate)
the terminal curser sits at a new line ready for the next command. Of course putting the ampersand "&" allows me to easily see the process id, which could be terminated. While testing this I managed to confirm making iftop into a 100% errant process, no idea how I triggered this, but it is observable that the command htop does not seem to trigger this. Eitherway, the above command worked perfectly to kill the process... ie:
sudo kill `ps aux | grep "sudo iftop" | awk '{print $2}'`
1.png