How to run multiple commands in the terminal


Sometimes you may want to run multiple commands in the terminal. Here is how to do it:

If you want to run multiple commands in the terminal respectively, just add a semicolon (;) between two commands. For example:
command1; command2; command3

With this syntax, it does not matter if a command returns to error, all the commands you use will be executed eventually.

If you want to run multiple commands in the condition that the previous command must complete successfully first before running the next command ( in other word, if the first command returns to error, the next commands wont be executed), 2 and symbols (&&) will be used in lieu of the semicolon. For example:
command1 && command2 && command3

If you want to run multiple commands in the condition that the next command will be executed if the previous one fails ( if the first command runs successfully, the next commands wont be run), the syntax will be:
command1 || command2 || command3
linux tips and tricks