How to create custom commands in Unix/Linux?

Create a bash script in your /usr/bin folder, it should look something like this

#!/bin/bash
Whatever combination of commands you want to run when you type this thing.

Its really that easy.

Just name the bash script what you want to type in to the terminal, and make it excecutable: chmod +x filename and you're good to go!


  1. Create a directory say "bin" under your home directory.
  2. Update your path variable to include this bin directory. Put this in .profile or .bash_profle file to make it permanent.

    export PATH=$PATH":$HOME/bin"

  3. Create a script say, "hello" and keep it in your bin directory. Give execute permission to the hello script by $ chmod +x hello.

    #!/bin/bash    
    echo My first program
  4. Reload .profile or .bash_profle:

    $ . ~/.bash_profile

  5. From any directory, you simply type:

    $ hello
    My first program

Easy, create an alias.

Say you want to write a command to cd into your download directory. And you want to call it cdd.

alias cdd='cd ~/Downloads' 

You can create any command you want.

Here is further information:
http://www.mediacollege.com/linux/command/alias.html