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.
$ nano ~/.bashrc
Here, bashrc means run the Bash file. Bash is located at /bin/bash . This file helps in creating 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'
In the above figure :
alias :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 first command that you want to execute.
In place of command 2 provide second command that you want to execute.
alias ok='echo hELLo WorlD; firefox'
echo hELLo WorlD it will display hELLo WorlD in terminal.
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 file. Now, Restart your terminal.
Now, whenever you will type ok it will execute your command.
Don’t use bashrc directly in spite of this we may use bash_aliases
# Alias definitions. # You may want to put all your additions into a separate file like # ~/.bash_aliases, instead of adding them here directly. # See /usr/share/doc/bash-doc/examples in the bash-doc package. if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi
Use bash_aliases to make your own aliases :
Please Login to comment...