Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create shortcut commands in the Ubuntu terminal?

Tags:

shell

ubuntu

For example, instead of typing all 5 commands in my terminal:

command 1
command 2
command 3
command 4
command 5

I just want to enter one command that runs all 5 commands above:

command everything

Is that possible? What would I need to edit in Ubuntu to do so?

like image 563
sjsc Avatar asked Nov 30 '22 04:11

sjsc


2 Answers

If you're running a bash shell, you can type

alias commandall='command1 ; command2 ; command3 ; command4; command5'

Then commandall will run these commands

You can put the alias in your ~/.bashrc file and it will be there whenever you log in.

like image 115
Dennis Sheil Avatar answered Dec 01 '22 17:12

Dennis Sheil


create a bash script.

#!/bin/bash
command1
command2
command3

then set its mode to executable

chmod a+x commandall

then you can call it from the command line

./commandall

if you put it in a directory in your PATH, you can call it like any other command.

~/bin
like image 28
The Lazy Coder Avatar answered Dec 01 '22 16:12

The Lazy Coder