Creating custom commands in Ubuntu

Creating custom commands in Ubuntu

In the next tutorial I will show you how to use alias  to create our own custom commands for use from terminal.

Although I do not recommend it, this is very useful for the most used commands in our Linux distro based on DebianIn this case Ubuntu 12.10.

The question of not recommending the use of tools like alias, is that despite its great utility, it can be counterproductive especially for users who are starting with this of Linux and its terminal, since although it is very useful and friendly to use custom commands, it can make us forget the real commands to use.

How to use aliases to create your own commands

Alias It is already installed by default in our Ubuntu, so to use it we will only have to edit the .bashrc file found in the Personal Folder in a hidden way.

The pattern to follow to create our own custom commands will be the following:

alias custom command= "original command»

The parts in italics will be the ones that we will have to change for our custom command and command to replace.

We will open the file .bashrc with the following command:

  • sudo gedit ~ / .bashrc

Creating custom commands in Ubuntu

Now we will add the lines with our custom commands, at the end of the file, as I indicate in the following screenshot:

Creating custom commands in Ubuntu

At the beginning we will put:

# Start my commands

And we will finish our custom commands closing with this line:

# End of my commands

We will save the changes in the File .bashrc and we will activate them with the following command: ç

  • source ~/.bashrc

Creating custom commands in Ubuntu

Now for update the list of repositories, as we have created the pertinent shortcut, we will only have to put the terminal to update:

Creating custom commands in Ubuntu

Creating custom commands in Ubuntu

As I said, it is a very useful tool for create our own commands and thus simplify the use of the terminal, although it should not be abused so as not to forget the real commands.

More information - How to rename files in bulk in Linux


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.