In this post, we'll look at how to write our own Linux commands, which will free up time for us to work on more useful tasks. It’s easy to set up and also a lot of fun as we can create any Linux commands from highly useful to just fun ones.
The foundation of the Linux operating system is its command line interface, which gives users strong tools to complete a variety of tasks. Although Linux includes a wide variety of built-in commands, there may be instances when you find yourself in need of a customized command suited to your particular requirements. We will walk you through the process of developing your own Linux command in this blog post, along with a real-world example to show its usefulness.
Without much ado let's dive right in.
Necessary prerequisites:
Linux Environment
Basic Terminal Knowledge
A Text Editor
Step 1: Open .bashrc or ./bash_profile
vi ~/.bashrc
#alternative
vi ~/.bash_profile
Step 2: Add your command in the bashrc file
alias sysup='sudo apt-get -y update'
Step 3: Source the bashrc file to apply changes
source ~/.bashrc
#bash_profile
source ~/.bash_profile
Added the above line in the bashrc file.
Here we can see we created our own command to get Linux updates. Now instead of using "sudo apt-get -y update" we can just use sysup which is a short and easy command.
In this way, we can create our own Linux command.
Happy Learning!!