How to create shortcuts on an Ubuntu terminal?

For example, instead of entering 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 it possible? What do I need to change in Ubuntu to do this?

+4
source share
6 answers

If you are using a bash shell, you can enter

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

Then commandall will run these commands

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

+16
source

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 variable, you can call it like any other command.

 ~/bin 
+4
source

Record a shell script, mark its executable, insert into your path and run it?

Alternatively, you can write a shell function, put it in your ~ / .bashrc file.

+1
source

You might be looking for bash aliases - try running here :)

+1
source

If you want each command to be executed in order, command1 && command2 && command3 && command4 && command5 should do. You can save it in a shell script and call the script when you need to.

If the execution order is not so important,

 command1 & command2 & command3 & command4 & command5 & 

.

You can also mix and match if you need a different execution order.

+1
source

According to this :

 $ (stsrun -v devel area1.exp; stsrun -v devel prime1.exp; stsrun -v devel treat.exp) & 
-1
source

Source: https://habr.com/ru/post/1348039/


All Articles