Linux Operating System allows custom commands, So anyone can write their own commands for their needs. That’s the power of Linux. I am going to show you how to create custom commands ( now - to shows current time) in Linux System,
Create Bash Script :
The First thing is to create bash script in /usr/bin/ Directory which will run your commands,
$ cd /usr/bin $ sudo vim now
Write the following code in the file,
#!/bin/bash now=$(date +"%T") echo "Current time : $now"
Save the file and get back to terminal.
Make as Executable :
The Second thing is to make the file as executable and readable with the following command,
$ sudo chmod 777 now $ sudo chmod -x now
Thats all, your “ now “ command is ready now. Test the command by typing “ now “ in your terminal, it should show the current time in that !
$ now Current time : 12:18:45
This is the sample to create custom command in Linux system, we can use the procedure to create more complex command too, if you have good knowledge in shell script.