3

Is there a way I can input these two commands into a new terminal at the same time?

( konsole -e sudo nethogs 
sudo sysctl net.ipv4.ip_forward=1 )
mo97
  • 31
  • 1
    Could you add some more context? What are you trying to accomplish by running these commands "at the same time"? – Zchpyvr Apr 08 '19 at 19:53

2 Answers2

5

I think what you want to do with konsole is the following:

$ konsole -e "sudo sysctl net.ipv4.ip_forward=1; sudo nethogs" --noclose --hold

This will invoke konsole and then run commands within it, -e. In this case we're running the 2 sudo commands and we're using the --noclose & --hold to tell konsole to keep the window open while these run.

slm
  • 3,035
  • root@MO-HP-EliteBook-8560p:/home/mo# konsole -e "sudo apt-get update; sudo apt-get update" --noclose --hold QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root' QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root' root@MO-HP-EliteBook- – mo97 Apr 08 '19 at 13:14
  • @mo97 - I cannot tell from what you posted, is it still not working? – slm Apr 08 '19 at 13:15
  • @mo97 - you might want to try using konsole -e "sudo whoami; sudo whoami" --noclose --hold to see what the issue might be more easily. – slm Apr 08 '19 at 13:16
  • Done everything you say .. This is the result .. QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root' QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root' – mo97 Apr 08 '19 at 13:25
  • @mo97, You can also test what happens with the following command line, konsole -e "sudo whoami; sudo whoami;bash" -- The final bash will make the konsole window stay instead of close immediately after finishing the previous commands. – sudodus Apr 08 '19 at 13:33
  • @slm Open the window and then ask for the password and then close it – mo97 Apr 08 '19 at 13:42
  • @m097 - I dug this up from the Unix & Linux site with the same error you're encountering. Can you try using gksudo instead of sudo? - https://unix.stackexchange.com/questions/382789/qstandardpaths-xdg-runtime-dir-not-set-defaulting-to-tmp-runtime-root-when – slm Apr 08 '19 at 14:13
0

To send several commands to different terminals simultaneously one easy way could be with byobu:

Press Ctrl+F2 to vertical split, then Shift+F9:

screenshot

screenshot

Pablo Bianchi
  • 15,657