Manuel Ignacio López Quintero

Do you like this article? Share it with this link. Thanks!

Create a terminal shortcut in Ubuntu or Debian

The terminal is an excellent tool for developers, but sometimes you need to type large commands with multiple arguments or run an application with a long path. The best way to resolve this is using a terminal shortcut or alias (more appropriate).

The syntax is: alias yc='tc', where yc is your command and tc is the terminal command. For example, we will create an alias named clc with the following command that totally clear the terminal screen: echo -en '\ec'.

1. Open your terminal

A terminal is a Command Line Interface (CLI) where you type commands to tell the computer what to do. Make sure you've opened the terminal, if so, continues in the next step.

2. Create a shortcut

There are two ways to create a shortcut: only for your user or for all users.

2.1. Only for your user

In your terminal, execute: nano ~/.bash_aliases.

Add the following line at the end of the file: alias clc='echo -en '\ec''.

Exit with Ctrl + X and save the changes. Finally, execute bash in your terminal. Now you can start using your shortcut clc!

2.2. For all users

In your terminal, execute: sudo nano /etc/bash.bashrc.

Add the following line at the end of the file: alias clc='echo -en '\ec''.

Exit with Ctrl + X and save the changes. Finally, execute bash in your terminal. Now you can start using your shortcut clc!

Do you like this article? Share it with this link. Thanks!