Home » Tech Tips » Custom Commands for Linux Terminal

Custom Commands for Linux Terminal

Linux operating system allows users to create commands and execute them over the command line. To create a command in Linux, the first step is to create a bash script for the command. The second step is to make the command executable.
Syntax :

 $ nano ~/.bashrc

Here, bashrc means run the Bash file. Bash is located at /bin/bash . This file helps in creating an environment with help of startup files. nano is text editor. Instead of nano, you can use gedit text editor which is GUI base and most of the users are comfortable with it. Then we have to search content as shown below.

# some more ls aliases
alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'

linux-custom-command-mytechmintalias :It allow to user to make custom commands.
unalias :It allow to user to stop working of any command.

Make custom command for our own purpose :

alias [name]=' [command 1]; [command 2]; [command 3]; .....  [command n]'

In place of name provide your custom command.
In place of command 1 provide the first command that you want to execute.
In place of command 2 provide the second command that you want to execute.
Example :

alias ok='echo hELLo WorlD'

echo hELLo WorlD it will display hELLo WorlD in termainal.
Enter your commands in sequence and then hit CTRL + O to save your commands in file.
Then, hit ENTER for the confirmation and then, hit CTRL + X to exit from the file. Now, restart your terminal.
Now, whenever you will type ok it will execute your command ‘echo hELLo WorlD’ and display hELLo WorlD in your terminal.

Leave a Comment