Friday, June 7, 2024
HomeA-Z CommandsHow To Run Multiple Linux Commands at Once in Linux Terminal

How To Run Multiple Linux Commands at Once in Linux Terminal

In Linux, you may need to run terminal commands simultaneously for installing and executing applications. If you’re a newbie in Linux, the chances are that you might be looking for methods to execute multiple commands at a time on your terminal shell.

In particular, system administrators need to perform a bunch of commands like ifconfig and GRIP commands to handle loads. Linux allows users to get a newbie to professionals through commands.

Knowing a handful of commands might make you different in the Linux community if you know how to use them and how to run multiple commands at once in the terminal on your Linux machine.

Multiple Linux Commands at Once in Terminal

Power Linux users love the key combination of Ctrl+Alt+T to find files, install tools, and execute other tasks. Putting different symbols and signs in between two commands can help perform multiple commands simultaneously on Linux. You can combine more than one similar command on Linux for better performance.

For instance, you can perform an apt update and upgrade command at a time by putting the & symbol in the command. In the entire post, we will see how to run multiple Linux commands at a time in the terminal shell.

1. Use the && Command

Executing combined commands on Linux with the & symbol is not a new thing. You can use the following format to combine two or more similar types of commands on Linux for powering up the system. The following command will update the system repository and then upgrade the repo.

sudo apt update && sudo apt upgrade

apt update and upgrade

Execute the following commands to make a new directory, browse the directory, and run the PWD command on the directory at a time through the && symbol.

mkdir new_dir && cd new_dir && pwd

make directory and PWD multiple command a t time on linux

2. Use the || Command

If you’re an experienced Linux user, you might already know that we can use a pipe (|) sign on the command to pass the output of the command. But you can use a double-pipe (||) symbol in the command for making an OR condition in the command. The logical OR operator will decide what to do if the prior command is failed or false.

For instance, we can set logical OR operation in the command for creating a new folder, browsing that folder, and printing the directory details. If the mkdir command fails, the next part of the command will also fail.

mkdir new_dir1 || cd new_dir1 || pwd

use pipe commands together

3. Use the && and || Command

In the previous method, we have just seen the use of double-pipe (||) and double and (&&) syntaxes on a terminal command. Here, we will use them together and run multiple Linux commands simultaneously.

For instance, the following command will create a new directory named newdir and print the status that the directory is created using the Echo command.

$ cd newdir || mkdir newdir && echo "directory is created"

directory is created run multiple command on linux

4. Use the / Command

In Linux, power users usually use the wget or cURL tool for downloading files. Then, we can copy or move that file to the desired directory. But you can also combine two commands in a single line to download and move the file inside the desired directory.

The following command will make a new directory inside the filesystem and move the downloaded file into that folder.

mkdir rpms/; mv foobar-1.3-2.i386.rpm rpms/

5. Use the ; Command

In different programming languages, the semicolon (;) symbol is used to end a line in a program. In Linux bash, you can use the semicolon (;) symbol to add more than one command in the same shell command to run multiple Linux commands.

For instance, here, we can browse a directory (ls command), print the directory path (through the PWD command), and see the current user details in the Linux system.

ls ; pwd ; whoami
$ ls ; pwd ; du ; whoami

use of semiclone for multiple commands

6. Use the / and ; Command

Till now, we have seen combining similar types of symbols to increase work efficiency. Now, we will see how to add and combine two different types of symbols in a single command and run multiple Linux commands at a time.

You can use the following command in the combination of / and  ;  for browsing a directory and removing the files. 

Please be careful before executing any rm -rf commands on Linux. It might delete important files with root access from your filesystem if you’re a newbie on Linux.

$ cd /my_directory ; rm -Rf *

7. Combination operator {}

The combination bracket operator functions for executing directory-level commands. It can be used for executing a command and print the output status. For instance, you can run the command below to make a directory and then pull the Echo command to check the directory status on your Linux machine.

$ [ -d temp ] || { mkdir temp; echo temp directory is created now.; } && ls

Combination operator

Final Words

Mixing things up is great in Linux if you know what you’re doing. Executing several shell commands on the terminal shell definitely makes you a professional Linux user. In the entire post, I’ve illustrated several methods to run multiple Linux commands at a time in the shell.

If you’re good with shell scripting, you can also make your customized commands to make things more professional. You can also open multiple tabs on the shell for running a bunch of commands at a time on your Linux system. If completing the prior command is not a prerequisite to the next command, it won’t cause any other issues.

I hope this post has been useful to you. Please share it with your friends and the Linux community if you find this post useful and informative. You can also write down your opinions regarding this post in the comment section.

Mehedi Hasan
Mehedi Hasan
Mehedi Hasan is a passionate enthusiast for technology. He admires all things tech and loves to help others understand the fundamentals of Linux, servers, networking, and computer security in an understandable way without overwhelming beginners. His articles are carefully crafted with this goal in mind - making complex topics more accessible.


  1. I’m not trying to be mean, but a lot of this is either flatly wrong (e.g., “/” is simply a component of a pathname, it is absolutely not a command or even an operator), or phrased in misleading or unhelpful ways. The WAY fast quickie tour of what each of these is and does. Note that all of these are *operators*, not commands:
    && — this is a logical AND and is used to chain multiple commands; commands to the right of the operator are executed if the command to the left succeeds
    || — this is the logical OR and is used to chain multiple commands; commands to the right of the operator are executed if the command to the left fails
    / — not a command, not an operator. Period.
    ; — this is a command delineator or separator; you use it to separate commands where you want all of them to execute
    {} (and () ) — operators that do a bunch of stuff; I tend to use () for grouping commands into one “unit”, and use {} for its command line expansions (a bit complicated to go into right here)


Please enter your comment!
Please enter your name here

You May Like It!

Trending Now