Understanding Linux sequences
Linux has some powerful sequence controls that you can use to run processes in different orders, sequentially, in parallel or conditionally.
Commands seperated by a ; are run sequentially. The shell waits for each command to terminate before returning. As seen in the gif it doesn’t matter if either command fails or not.
Commands seperated by a && are run one after another and the second command is only run if the first one returns an exit code of zero aka runs successfully.
A command with a & at the end of it runs in the background and does not wait for the command to finish and returns immediately successfully with an exit code of 0. It returns with an exit code of 0 even if the command itself fails.
The standard output of command1 is sent to the standard input of command2. So in this example we’re using cat to output the standard input which is the echo’ed statement.
The command after the || is executed only if the command before the || returns a non-zero status aka it errors. It is akin to an OR operator.
Is shorthand for 2>&1 | which means the standard output and standard error of the command are sent to via the pipe to the following command.
Read more about here