Ubuntu – How to execute several commands after each other with one request to the terminal (without using a file)

command linegnome-terminal

I could (1) prepare a file with typed commands separated by end-line, (2) make it executable, (3) run it from a file-system manager or the terminal.

But this is ridiculous for not repeatable and every-time-other sets of commands.

Can I type those commands to the terminal in one request instead?

I don't know end-line character for the terminal – Ctrl, Shift or Alt with Enter doesn't work.  

Best Answer

You can separate commands with && or ;.

  • && only runs the next command if the previous one exited with status 0 (was successful) :

    command1 && command2 && command3
    
  • ; runs every commands, even if the previous one exits with a non zero status :

    command1; command2; command3
    

You can combine these separators as you wish.

Related Question