Chaining Linux Commands Together

Written By
Web Webster
Web Webster
Feb 3, 2009

[ Thanks to Brandon for this link.
]

“What if you wanted to run a command and when it
finished, run another? Linux provides three ways to do this with a
slightly different end result. The semicolon (;), ampersand (&)
and the verticle pipe (|) all help the user “chain” commands
together.

“[user@localhost ~]$ apt-get update ; apt-get upgrade

“In this example we are using the semicolon (;) to separate
these two commands. Using a semicolon tells the shell, “once the
first command finishes, run the second one”. Once apt-get update
finishes, the system will then run it again using the upgrade
option.

“[user@localhost ~/project1]$ ./configure && make
&& make install

“This command is mainly used by developers, software package
maintainers and Linux power users. This chain of commands compiles
a program and installs it. What the double-ampersands are telling
the system is “wait for the first command to successfully complete.
If it does complete successfully, run the next command”.

Complete
Story

Web Webster

Web Webster

Web Webster has more than 20 years of writing and editorial experience in the tech sector. He’s written and edited news, demand generation, user-focused, and thought leadership content for business software solutions, consumer tech, and Linux Today, he edits and writes for a portfolio of tech industry news and analysis websites including webopedia.com, and DatabaseJournal.com.

Linux Today Logo

LinuxToday is a trusted, contributor-driven news resource supporting all types of Linux users. Our thriving international community engages with us through social media and frequent content contributions aimed at solving problems ranging from personal computing to enterprise-level IT operations. LinuxToday serves as a home for a community that struggles to find comparable information elsewhere on the web.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.