Linux terminal how to create your own commands

Linux terminal how to create your own commands

In linux you can rename commands. This feature is called an alias, and is used to create aliases for commands, making them easier to execute.

How do I create an alias?

The structure for creating an alias:

alias alias_name='command'

In this way, we can create new commands.

To create them, you need to modify the .bashrc file in the /home/Username/.bashrc directory. If it doesn't exist, create the file and add each alias at the end of the file.

Open with your preferred editor:

sudo editor ~/.bashrc

An example is shown below:

alias upsystem='sudo apt-get update && sudo apt-get upgrade'

To save the changes, once and for all:

source ~/.bashrc

How to use it?

Once added to the end of the .bashrc file, simply execute the new command using the alias.

upsystem

Don't forget to add a reaction if the post has helped.