Create custom Linux commands

How to createcustom commands or rename existing ones?

Without any doubt, it is a question that many of us have done at least once, either for easy recall a command instruction we want to make more funny a command or save time by writing. Learn to how to do easy and simple way thanks to a command available in several shells, his name is "alias" (In all GNU / Linux) and other simpler form (For those with terminal Deepin) .


Method 1
To do this we need to open our terminal, you can search launcher Deepin or the keyboard shortcut "Ctrl + Alt + T" after opening the terminal we can start creating aliases or nicknames for commands specific or complete instructions.

A specific command would besudo and a full statement would be sudo apt updateIn both cases, you can create an alias, with minor differences.

For the first we might think of something that makes us help you remember the "sudo" command command, used to run a command with elevated or "root" or administrator privileges, so you could put a nickname to this command. Examples:

Example 1: alias administrador=sudo Easier to remember.
2nd Example: alias s=sudo To write faster.
3rd Example: alias sudar=sudo To fool around, you can invent the command you want.

Now, suppose we will open the Synaptic package manager or anything else with elevated privileges or need "sudo" in the terminal, we could use our new command "sweat"

However, when there is a single command, but a complete instruction as could besudo nano /etc/apt/sources.list(This address is where addresses are stored repositories), then, should be done using simple '' 'quote or quote the English' '' and wrapped the entire command between two of them. Examples:

Example 1: alias repositorios='nano /etc/apt/sources.list'
2nd Example: alias actualizar='sudo apt update'
3rd Example alias mejorar="sudo apt full-upgrade"
4th Example: alias instalar='sudo apt install'

Then, using one of our new commands in the terminal, would something like this:

As you can see, it is very easy and simple, you will keep the original commands but also have these that will make use of something more fun and less frightening terminal, in the event that you want to delete an alias or nickname, we would use the command unaliasfollowed by the name. Examples:

Example 1: unalias instalar
2nd Example: unalias actualizar

Then note that when writing instructioninstalar vlcwould "command not found"

To see the list of aliases you've invented you can only use the commandalias.


2nd Method
All this was for educational purposes because if you get too lazy, you can simply create a custom command by right clicking on the menu Deepin terminal and press the option that says "Custom Commands"

Then to use it you would have to open the terminal and press it every time you go to use it, rather than typing a command in the terminal on your own.

Using aliases allow us to adapt to the terminal, handle a little better and faster.


What do you think about it?

please Enter to comment
7 Comment threads
4 Responses thread
Comment with more reactions
Highly Commended thread
7 Authors comments
Isaías Gätjens MCarLain IwakurasarchSilviaAuthors of the most recent comments
Newer oldest More popular
Report of

persistently to add aliases and save them to restart the machine can do the following: open a terminal and edit the bashrc with the following command (I'm using nano but you can use vim or your favorite editor

nano ~ / .bashrc

and add at end of file

#inicio my aliasalias update = "sudo apt update" #end my alias

then make a

source ~ / .bashrc

and we have our custom alias permanently salu2


I use a .bash_aliases, I have always available and permanent, plus I can get some functions, I think it's easier

Fernando Zamora

Very useful, thanks.


I JHalo terrific! Thank you!

Lain Iwakura

¿Cómo puedo hacer que funcionen los alias con el comando cd?

DeepinScreenshot dde desktop 20200305203148

Tengo un alias que es, por ejemplo:

alias Películas=’/home/user/Movies’

Pero cuando uso el comando

cd Películas

Me aparece que no existe el archivo o directorio.


AvatarLain Iwakura And why should equal Movies Movies? except your fantasies xd


Lain Iwakura


Es solo un ejemplo.

Lo que pasa es que en otra computadora tengo un servidor de streaming creado con Streama. Es una laptop sin pantalla (porque se me rompió hace mucho tiempo), entonces la uso con ese fin. La única forma que tengo para controlarla es por medio de SSH. Entonces cuando requiero hacer alguna modificación de un archivo tengo que poner el directorio completo, hasta que vi este artículo que me alegró la existencia.

Creé el alias como se indica: [Nombre de alias]='[directorio]’

Funciona bien con el comando cp pero con cdls no funciona, me aparece que el directorio no existe.



AvatarLain Iwakura Well that is another issue, your problems are external routes, as these in Telegram because we talk is not there more practical

Lain Iwakura


Disculpa que no haya seguido la conversación cuando me respondiste, pero en mi zona horaria ya era muy tarde.

Te agradezco el apoyo.


Isaías Gätjens M


Hola, un detalle es que no debe confundir alias con variables del sistema, alias es para crear alias de comandos, no de ubicaciones de carpetas, solo comandos. Claro, el comando puede incluir una ubicación de carpeta o archivo, pero el alias tiene que tener un comando.

Mi recomendación es usar enlaces simbólicos, teniendo en cuenta que el comando cd sin parámetros siempre me lleva a la carpeta de usuario, /home/hurondefuego (que es guardado en la variable del sistema ~ ) en su caso, puede crear un enlace simbólico en su carpeta de usuario.

cd ~
ln -s /home/hurondefuego/strema/media/movies stremamovies

Esto creará el enlace simbólico en su carpeta de usuario.

Luego para ejecuta

cd streamamovies

Y eso lo llevará a /home/hurondefuego/strema/media/movies.


Otra forma si quiere hacerlo con alias sí o sí es usar

alias stremamovies='cd /home/hurondefuego/strema/media/movies'

Entonces sin importar qué carpeta esté, cuando ejecute stremamovies eso lo llevará a /home/hurondefuego/strema/media/movies.

Pero no soy muy partidario de este tipo de soluciones con alias, me gusta ver exactamente lo que se ejecuta para evitar errores.




Lain Iwakura


Muchísimas gracias.