Linux - Create your own command

October 2016

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.The script can be run only after file permissions have been changed to executable mode. Once changed, copy it to the binary path of Linux so that it can be run just like system-defined commands of operating systems. Follow these easy steps to create a command in Linux.


Below are the steps to create your own command on Linux.

Creating a Bash script

The first step is to create a Bash script which will run your command.


#on displays the actual folder name      
echo "the folder is 'pwd'"      

#then the rest of the files      
echo "The folder which contains files are 'ls'"
  • Save this file (CTRL + O with Nano) give it the name of your command (Example: FileInfos).

Make the command executable

  • Try to type the name of your bash script, you will notice that it will be executed (run).
  • Now you have to modify the CHMOD of the script which you will run by typing:
    • chmod +x yourScript
  • Now, copy your script in the path, /usr/bin like below:
    • cp yourscript /usr/bin/
  • Now you are done! Run your command by typing the script name which you moved in /usr/bin.

Related :

This document entitled « Linux - Create your own command  » from CCM ( is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.