Creating Custom Linux Command

Sometimes you may need to repeat lots of linux command on terminal for any aim. It is some time so boring to type all the commands again and again so the solution to create  own commands to execute all the repetition in one.

All the commands are kept on /bin directory s we just need to create a file and name as the command that we’ll use. Then we need to make the file readable and executable.

For example I create a apache server restart command.

– Go to /bin path: cd /bin

– Create the command file with the command name:sudo touch apacherestart

– Make the fie readable and executable: sudo chmod +rx apacherestart

– Open the file and write the command we’ll use the new one instead of it: sudo /etc/init.d/apache2 restart

That’s all. After now, we might use the new command to restart apache server: apacherestart

Share