Launching a new gnome-terminal from a gnome-terminal and running a command

I am running Ubuntu 19.04 (Disco). I use ctrl+alt+t to launch a terminal window. From that window, I would like to launch a separate window that runs a command, say ls. My thoughts are that I would type gnome-terminal -- ls and it would work, but it a new window is not launched.

That said, if I simply type in gnome-terminal and hit enter, a new window launches (but without running the command I would like to be run in a separate window.

The overall requirements are very strict, because what I what I am doing. (I am actually trying to launch this window via an ssh connection, running as root, in a root Desktop session)

1

1 Answer

I'm assuming that you want the new gnome terminal to stay open indefinitely. If so, you can try something like:

gnome-terminal -- bash -c 'ls; exec bash' 

The exec bash after the ls command ensures that the new terminal stays open, otherwise you can use the sleep command instead to have it close after a certain ammount of time:

gnome-terminal -- bash -c 'ls; sleep 30' 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like