Suggest a StoryDo you have a news tip? We would like to hear from you.

[How To]: Execute Multiple Commands in Terminal

Running multiple commands really helpful in many ways for installing packages, copying files, moving files, …. .Sometimes when you try to install a package output message show that you have install extra dependencies, this will be really annoying to install them one by one. with these commands will make it easily for you to write it once for all.

Execute the second command if the first command successful or execute the third command if the first and the second successful

sudo apt-get install pidgin && cd ~/Music && cd ~/Downloads

in this case if write all commands correctly the output should be opening “Download directory” after finishing the installation for “Pidgin” application.

AND logical gate.

Execute the second command if the first failed or execute the third command if the first and the second commands failed.

sudo apt-get install kats || cd ~/Musc || cd ~/Downloads

in this case i missed spelling kate application and wrote it “kats” instead of “kate”, also music directory, but last command wrote correctly so it will execute the last command.

OR logical gate.

Execute commands regardless these command are correct or not.

you will just need add semicolon “;”between them.

sudo apt-get install kate; cd ~/Musfdic; cd ~/Downloads

you can add as much as you want of commands.


Support Us By Sharing

Leave a Reply

Enjoy LinuxNov? Please spread the word :)

  • +LinuxNov
  • LinuxNov
  • LinuxNov