Create Your Own Command in Linux

Ask a question
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.

This tutorial will walk you through both steps and show you how to create your own command in Linux.

Creating a Bash Script

To create a bash script, enter the following code:


#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 by pressing CTRL + O with Nano. Give it the name of your command.

Make the Command Executable

If you 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 that you will run by typing:

chmod +x yourScript

Now, copy your script in the path, /usr/bin, like below:

cp yourscript /usr/bin/

You're all done! Run your command by typing the script name, which you moved to /usr/bin.

Image: © Signs and Symbols -

UNetbootin - Installing Linux using a pen drive (bootable USB)
Super Grub disk Live CD