Is there a difference between using && and ; in Linux commands?

I’ve been experimenting with combining command on one line. I’ve found && and ; give the same results. Are these interchangeable or is is there some subtle difference between the two?

Posted by Steve in Linux Users Group.

1 Like

There is a BIG difference between the two. If you use && and if the first command doesn’t run successfully, the second command won’t run.

With ; there is no such thing. The second command will run irrespective whether the previous command succeeded or not.

9 Likes

Very good tp know the difference between && and ;
Thank you

Wicklowham

5 Likes

I drew an infographic explaining that.
Usually, I share the link only if you register on my mailing list. But for itsfoss.community members, here is a direct link to download the PDF

https://drive.google.com/file/d/113ASfatibe4UaX15r_4haumo3BPdluwp

If you want to share that with your friends, please point them to https://www.yesik.it/SHELL10 – or ask them to register on https://itsfoss.community :smiley:

4 Likes