Header AD

How to create custom commands in Unix/Linux?

How to create custom commands in Unix/Linux?
How to create custom commands in Unix/Linux?

How to create custom commands in Unix/Linux?


Create Your own Commands with Alias on Linux


Alias command allows us to create our own custom commands.This is really very useful.If you are regular Linux user or administrator then it should help you.
We can create aliases of just about any Linux command you can think of. Not only commands also the application that is installed in your system you can create custom commands for everything.

Create an alias for Firefox

Firefox is default web browser for almost every Linux distribution.So in order to open firefox from your terminal, you type firefox but it can be made a little easier with the alias.Follow the below command:
root@seven:~# alias web='firefox'
When you execute the above command the command firefox gets assigned to the web.So now you don't have to type firefox in order to start firefox. The Just web will do it.
root@seven:~# web
So when I write the web my firefox starts.You can assign any name even a single character will do it.

Making switching easy with alias

Lets you want to change your directory to Desktop then regular syntax goes like this:
cd Desktop its kind of lengthy I mean we can make to easier.Just follow the below command:
root@seven:~# alias desk='cd Desktop'
Now you don't have to type cd Desktop to switch desktop.The Just desk will do it.
root@seven:~# desk
root@seven:~/Desktop# 

List created aliases

If you want to know about aliases that you created just type alias.It will list all the aliases created by you
root@seven:~# alias
alias desk='cd Desktop'
alias ls='ls --color=auto'
alias web='firefox'

Remove aliases

If you want to get rid of aliases then follow the below command:
root@seven:~# unalias web
Just give the command that you want to alias along with the unalias command.

So above are the How to create custom commands in Unix/Linux?. Hope you like this article, keep on sharing with others too. Also, share your experience with us in a comment box below.

No comments