Create Your Own Command In Linux
If you hear open source any where, the first thing that comes to our mind is Linux and Android even though there are many open source operating systems have used to come.
But, many people think that there are more difficulties while using Linux than Windows. Actually that's not the fact, only the interface is different. Linux is more flexible and more secure to users. It allows users to change the existing commands by masking with their own commands. Using Linux is not difficult if you continue to use it.
Here is the Simple example to show that Linux is user compatible:
Linux operating system permits end users to make commands and execute those over the command line.
In order to create a command in Linux,
1. The First step is to create a bash script for the command you wish to change it as your own command.
2. The second step is to make the command as an executable command and also you have to change the file permission of the script that you have created.
3. Once if you created the script and changed the file permission to executable mode, copy that script file into the binary path of Linux so that it can be run as like as the normal commands that is system defined commands.
Here you can easily get an idea:
Step 1:
The very first step is to create a bash script that can run your own command
>> Create file using vi filename(The command name you wish to substitute for the standard system defined command line such as ls, pwd, etc...)
Ex, vi own(file name)
Step 2:
After creating the file type the below into that file
#!/bin/bash
echo "Make own command to list the files of the current directory give ls in this file"
ls
Then save the file using ":wq" command.
Step 3:
You need to change the file permission in order to make the file as an executable file. That can be done by chmod command
Ex, chmod +x own(file name)
Step 4:
Then Copy the file to the binary path of the Linux Operating System like below example
Ex, cp own(file name) /usr/bin
That's done.
But in sudo (super user do) you cant able to copy that file to /usr/bin, it will not provide permission. In that case, you have to jump into root user account for that , just type su then you will be asked for the root password. Give the current account password if you don't create any root account else give that root account password.
After jumping into that root account just copy the file using the above command. Like this you can make any command as your like commands.
Now that's done.
>> Just type own(filename)-it will list all the files present in the current directory.
Hereafter you can list the files using the command you did create.
It is easy to make Linux as you want but that needs some basic knowledge of Linux and script.
But, many people think that there are more difficulties while using Linux than Windows. Actually that's not the fact, only the interface is different. Linux is more flexible and more secure to users. It allows users to change the existing commands by masking with their own commands. Using Linux is not difficult if you continue to use it.
Here is the Simple example to show that Linux is user compatible:
Linux operating system permits end users to make commands and execute those over the command line.
In order to create a command in Linux,
1. The First step is to create a bash script for the command you wish to change it as your own command.
2. The second step is to make the command as an executable command and also you have to change the file permission of the script that you have created.
3. Once if you created the script and changed the file permission to executable mode, copy that script file into the binary path of Linux so that it can be run as like as the normal commands that is system defined commands.
Here you can easily get an idea:
Step 1:
The very first step is to create a bash script that can run your own command
>> Create file using vi filename(The command name you wish to substitute for the standard system defined command line such as ls, pwd, etc...)
Ex, vi own(file name)
Step 2:
After creating the file type the below into that file
#!/bin/bash
echo "Make own command to list the files of the current directory give ls in this file"
ls
Then save the file using ":wq" command.
Step 3:
You need to change the file permission in order to make the file as an executable file. That can be done by chmod command
Ex, chmod +x own(file name)
Step 4:
Then Copy the file to the binary path of the Linux Operating System like below example
Ex, cp own(file name) /usr/bin
That's done.
But in sudo (super user do) you cant able to copy that file to /usr/bin, it will not provide permission. In that case, you have to jump into root user account for that , just type su then you will be asked for the root password. Give the current account password if you don't create any root account else give that root account password.
After jumping into that root account just copy the file using the above command. Like this you can make any command as your like commands.
Now that's done.
>> Just type own(filename)-it will list all the files present in the current directory.
Hereafter you can list the files using the command you did create.
It is easy to make Linux as you want but that needs some basic knowledge of Linux and script.





Comments