DEV Community

Cover image for How to Make Your Own Commands in Linux Terminal
Antonio Silva
Antonio Silva

Posted on

How to Make Your Own Commands in Linux Terminal

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'
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

An example is shown below:

alias upsystem='sudo apt-get update && sudo apt-get upgrade'
Enter fullscreen mode Exit fullscreen mode

To save the changes, once and for all:

source ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

How to use it?

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

upsystem
Enter fullscreen mode Exit fullscreen mode

Top comments (0)