How to create your own linux command ;-)

Hi Friends,

Linux gives us lot of general commands and we have to use a lot many commands to finish a specific task. What if we can create our own command and fire them to do our specific task / repetitive task.

You care create alisa which can contain set of commands. For example each time when I have to check if mongo is running on my box I have to type a big command, how about being creative a publish command with name psm => which means it will ps all process and will figure out the mongo process 😉

alias psm=”ps -eaf | grep mongo”

syntax : alias commandName=“cmd1 ; cmd 2 ; cmd 3”

To persist alais as command forever, save that  in .bash_profile
and reload it using command source ~/.bash_profile

# create your own command for session 

> unalias prem => will remove the alias for that session, you might want to remove from .bash_profile to remove it permanently. 

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.