• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Source Digit

Source Digit

Linux, Ubuntu Tutorials & News, Technology, Gadgets & Gizmos

  • Home
  • How To
  • Ubuntu
  • Instagram
  • Blogging
  • Android
  • WordPress
  • +More
    • Cloud Computing
    • Gadgets
    • Social Media
    • Technology
  • Write for Us
Home / How To / Run Multiple Commands In Linux Shell Script

Run Multiple Commands In Linux Shell Script

By Sourabh / May 24, 2023 Category: How To, Ubuntu

How to run multiple Linux commands at once or run multiple Linux commands in one line. Running multiple commands in a single line Linux is easy, learn how:

How to Run Multiple Linux Commands in One Line

There are 3 ways to run multiple commands in one line in Linux:

  • ; Command 1 ; Command 2 – This will run command 1 first and then command 2
  • && Command 1 && Command 2 – This will command 2 only if command 1 ends successfully
  • || Command 1 || Command 2 – This will command 2 only if command 1 fails

See below to learn the use in full details:

  1. Using ;

When you use ; no matter the first command (command 1) run successfully or not, always run the second command (command 2).

  1. Using &&

When you use && the second command (command 2) will run only when the first command (command 1) run successfully.

  1. Using ||

When you use || the only when the second command (command 2) will be executed only when the first command (command 1) fails to run.

Running more than 2 commands at once in one line

You can use ; to run multiple Linux commands in one line. Simply use semicolon (;) to add/combine multiple commands in single line. The following format can be used:

command 1; command 2; command 3

NOTE: The command 1 will run first, then command 2 will run and then the command 3 will run. The commands will run irrespective of whether the previous command has beene xecuted successfully or not.

Similarly you can use command 1 && command 2 && command 3.

Primary Sidebar

Latest Posts

Delete Directory And Contents Recursively Without Prompt On Linux

Check User Login History In Ubuntu Linux Command Line

Use Locate Command To Find File In Linux Terminal By Name

How To Change Terminal Color In Ubuntu Command Line

How To Run Fsck Manually In Linux To Fix Unexpected Inconsistency

How To Fix Broken Packages On Ubuntu From Terminal

Re Execute The Previous Command In Linux Ubuntu Command Line

How Much RAM Is Needed For Ubuntu PC

How To Find Large Files And Directories In Linux Command Line

How To Use Clear Command History In Linux Terminal

© 2026 Source Digit • Linux, Ubuntu Tutorials & News, Technology, Gadgets & Gizmos

  • Home
  • About
  • Privacy Policy
  • Terms & Conditions
  • Contact Us
  • Sitemap