0

I want to run the command HTOP, nethogs, and a bunch of other commands each in its own terminal tab as Ubuntu starts. I always have to manually start a terminal and type the same commands over and over. To be clear I want to:

  1. Open One terminal with multiple tabs on startup
  2. In each of these terminal tabs run a different command automatically
$ vim ~/.config/autostart/Apps.desktop 
#!bin/bash
gnome-terminal --tab Htop -e htop --tab Nethogs -e nethogs --maximize  

is that the correct format ? !wine will open a wine command with others, atleast thats how it does now in the terminal. It does not seem to work. Well it will work if you run the program as the root in the terminal. But it will not run after the boot takes place.

7
  • You can add sudo -u [username] screen -dmS [screenname] [command argument argument2] ... to /etc/rc.local. This will start a detached session attached to your user with name screenname and command command argument argument2 on startup. Oct 20, 2016 at 14:02
  • Can you provide an example. Can crontab also be used ?
    – devilz
    Oct 20, 2016 at 14:05
  • 1
    Combined with: askubuntu.com/questions/351582/…
    – muru
    Oct 20, 2016 at 14:13
  • In the duplicate it only states how to open a terminal, not how to open commands in each terminal tab.
    – devilz
    Oct 20, 2016 at 14:34
  • @devilz askubuntu.com/questions/2153/…
    – muru
    Oct 20, 2016 at 14:39

1 Answer 1

2

A bit late response but this is what works for me on Ubuntu 16.04

Modifiy sudoers. You will need to go to root mode.

sudo visudo -f /etc/sudoers.d/override

Inside you will make an exception for your script:

username ALL : NOPASSWD: /path/to/script

Then make a script for nethogs and other apps that need sudo permission separately:

!#bin/bash
sudo nethogs

As far as I know Htop doesn't need sudo permissions so you can proceed without doing this for Htop.

Go to dash and type in startup applications, click on it, and click add new. Under the command of the startup app type in:

gnome-terminal -e "sudo /path/to/script"

It will open what is inside the script and needs sudo permissions without asking for a password. You will also want to add in which profile it should open so you can edit the terminal to stay open after executing, for apps like Htop and Nethogs.

gnome-terminal -e "sudo /path/to/script" --window-with-profile=nethogs

Then make the same startup app for Htop.

gnome-terminal -e "htop" --window-with-profile=htop 

To edit the terminal, click on it, go to preferences, and then to profiles, add new and name it, click edit and then you'll know what to do.

4
  • nethogs and some of the other apps need sudo permissions. You could eliminate making a new script by providing a full path to the apps both in sudoers and startup applications but this is the short version. As for profile, you will want nethogs and htop to stay open after executing so you need to edit the profile and set the temrinal to stay open. You will need to add new name with htop and edit it though. You can also set width and length, just for htop and also for nethogs and any other app. Hopefully this makes things clear.
    – user633551
    Jan 8, 2017 at 15:30
  • actually you will want for the gnome-terminal to open each app separately so it's best if you do it one at the time. It was my bad to include && in the script.
    – user633551
    Jan 8, 2017 at 15:42
  • It does :) I was more like thinking to make the script open 2 separate terminals so it would be like gnome-terminal -e "sudo nethogs" --window-with-profile=nethogs && gnome-terminal -e "htop" --window-with-profile=htop and then just run the script as a startup app with both of the above terminal profiles set to stay open but I haven't tested it yet so I'm not sure if it works.
    – user633551
    Jan 9, 2017 at 21:08
  • got no dash in my Ubuntu, using the Nebula desktop.
    – devilz
    Jan 13, 2017 at 7:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .