first sorry for bad english. Second, I'm creating a cloning tools. I'm using the command

sudo mate-terminal --geometry=50x10 -x sh -c "sudo dd if=/dev/sda of=/dev/sdb status=progress; bash"

I'm using this command so that when user click on clone button link with the command above, the user can see the progress of the cloning which display some sort of a log of time remaining and transfer per second on a new terminal like in this picture.

The problem now is I'm using a touch screen device to create this tools and after the cloning is complete the terminal wont auto exit. User needs to click the "x" button to close the terminal and this would be a problem because I'm using a 3.5" touchscreen display and it can be pretty hard to click on the "x" button on a small touchscreen. When the cloning process is done it displays this on the terminal

I've already tried

exec ./clone.sh


./clone.sh && exit


./clone; exit

But all fail.

For your information, the command is link to a button so my command is like this

(action)./clone.sh && exit(/action)

Can anyone help me ?

  • add 'exit' at the end of the clone.sh main routine code and run: ./clone.sh && exit. does it work now?
    – Neni
    Oct 6, 2016 at 8:23
  • @Neni do you mean add exit in the clone.sh script itself ? If so, I've just tried it but no luck
    – Najmi
    Oct 6, 2016 at 8:41
  • And thank you @Zanna for editing the question so it is easier to read :)
    – Najmi
    Oct 6, 2016 at 8:45
  • 1
    You're very welcome. I just found the second picture. I'm wondering if you need to exit twice since you spawned a new shell... also have you seen this question askubuntu.com/questions/611648/… ?
    – Zanna
    Oct 6, 2016 at 8:56
  • @Zanna there's only one shell actually which is the progress log because the tools is in GUI created from gtkdialog-0.8.3. Yes I've come across that question. I've tried all the answers but still no luck.
    – Najmi
    Oct 6, 2016 at 9:27

1 Answer 1


The reason the terminal remains open is that you are telling it to run the dd command and then start a new bash instance. If you remove the bash from the end of the command, the spawned terminal will disappear as you expect.

Also, there's no reason to run the dd with sudo if you're already running the terminal with sudo. Only one of the two needs to be run with sudo, which one is up to you. You also don't need the sh -c since you only want to run a single command. Just use the -x directly.

So, taking all this together, what you are looking for is:

sudo mate-terminal --geometry=50x10 -x dd if=/dev/sda of=/dev/sdb status=progress

IMPORTANT: To anyone else reading this Q&A, this command is dangerous so don't run it on your computer. It will overwrite the contents of your /dev/sdb if you have one. It's what the OP wants to do, but you shouldn't run it unless you know what you're doing.

  • Oh my god it worked. Thank you thank you so much @terdon . I'm actually still in the learning process in this ubuntu universe so I thank you good sir :)
    – Najmi
    Oct 6, 2016 at 16:49
  • Oh and kudos for the disclaimer. It is indeed a dangerous command
    – Najmi
    Oct 6, 2016 at 16:50

You must log in to answer this question.

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