#ViernesDeEscritorio, Linux Mint 21.3 “Victoria XFCE. Curso de Manejo de Terminal parte 6. Comando ‘‘alias’’ uso y funcionamiento . ESP/EN.

Captura de Pantalla


cintillo_hive.png


Saludos #Lunuxeros, miembros de la comunidad de #Linux&SoftwareLibre y toda la comunidad de #Linux en #Hive, bienvenidos a un nuevo post de #ViernesDeEscritorio .

Este viernes, es la última, parte del curso, sobre el manejo y uso del Terminal. En esta parte del curso vamos a aprender qué es y cómo usar el comando ‘‘alias’’ ya con este comando, podemos hacer abreviaturas en los comandos que usamos en el terminal, lo que nos permitirá optimizar nuestro trabajo cuando estemos en la consola de #Linux.

Terminamos con este comando, ya que con lo que hemos aprendido en el taller, conocemos todos los procesos básicos que nos permitirán trabajar de manera segura y eficaz en la terminal de #Linux. Ya quedaría después, que uno siga aprendiendo y profundizando, pero la ventaja es que lo haremos con una buena base, que nos permitirá avanzar con seguridad.

Es bueno recordar, antes de continuar, que siempre debemos ejercitar lo que vayamos aprendiendo para que no se nos olvide y así avanzar con seguridad en el uso de muestro sistema #Linux.


¿Qué es el comando ‘‘alias’’?


Cuando hablamos del comando ‘‘alias’’ estamos hablando de una herramienta que nos va permitir crear una conexión a un comando más largo. Esto nos va a permitir abreviar nuestros comandos en la terminal, a través de la creación de un atajo más corto que nosotros creemos.

Es decir, haremos un shortcut, que es un termino que informática se refiere a un atajo, o un acceso rápido y directo. Puedes leer mas sobre este término aquí

Otro de los puntos que debemos tomar en cuenta con al comando ‘‘alias’’ es que normalmente, el shortcut que creemos, trabajará mientras dure la sesión del terminal abierta, una vez que se cierra, se pierde la creación de la abreviación que hicimos.

Sin embargo hay una forma de que quede fija que la veremos un poco mas adelante.


¿Cómo se usa el comando ‘‘alias’’?


El comando ‘‘alias’’ tiene una sitaxis o forma de escribirse que es la siguiente:

alias abreviatura="El comando o grupo de comandos que quieras sustituir por el alias"

Ejemplo: supongamos que yo quiero hacer un ‘‘alias’’ con el comando ‘‘ls’’ en ese ‘‘alias’’ quiero poner que el comando me dé el listado con forma de lista y me liste todos los archivos. Lo haríamos así:

alias lc="ls -l -a"

Ver imágenes.


Captura de pantalla.


Captura de pantalla.


¿Cómo hacer para que las abreviaturas hechas con ‘‘alias’’ queden fijas?


Debemos recordar que podemos hacer diferentes abreviaturas con un mismo comando y con diferentes comandos, esto lo haremos según nuestras necesidades en la terminal.

Voy a poner otro ejemplo, ya arriba vimos como colocar una abreviatura con ‘‘alias’’ en el comando ‘‘ls’’, pero haremos una para actualizar los repositorios y buscar actualizaciones de paquetes.

Sería así: alias pp="sudo apt update && sudo apt upgrade"
Pero yo ahora, quiero que la abreviatura ‘‘pp’’ quede fija para actualizar los paquetes cuando yo desee.
Para hacerlo debemos hacer lo siguiente:

  • Vamos a crear un archivo, lo podemos hacer con cualquier editor de texto, yo use ‘‘xed’’ que viene con Linux Mint. Y le ponemos un nombre que nos ayude a ubicarlo yo le puse .bash_alias_oso

ver imágenes


Captura de pantalla.


Captura de pantalla.


- Ahora colocamos todos los ‘‘alias’’ que deseemos, yo en principio solo colocare los dos ejemplos.

Ver imagen


Captura de pantalla.


  • Ahora guardamos y cerramos el archivo.

  • Ahora nos vamos a nuestra carpeta personal si lo queremos hacer del modo gráfico y le damos a las teclas Ctrl + h, para que nos muestre todos nuestros directorios ocultos y buscamos el directorio que creamos en mi caso .bash_alias_oso, la abrimos y colocamos el siguiente texto:

if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi

ver imágenes.


Captura de pantalla.


Captura de pantalla.


  • Ahora guardamos y cerramos el archivo.

  • Después abrimos la terminal y leemos el archivo con el siguiente comando:
    source ~/.bash_alias_oso (en el caso de ustedes serías source ~/.bash_ + el nombre que le colocaron al directorio)

  • Finalmente probamos nuestras abreviaturas hechas con el comando ‘‘alias’’ y veremos que funcionan bien.

  • Ojo, recuerda que para que el comando de los ‘‘alias’’ que creaste se active y los puedas usar, debes colocar el comando ‘‘source ~/.bash’’ más el nombre de la carpeta donde creaste los alias.

Ver imagen


Captura de pantalla.


Recuerda que si estas haciendo muchos trabajos en la terminal y deseas crear varios alias más, simplemente los realizas, compruebas que funcionen bien en el terminal y después lo colocas en el archivo que creaste, que en mi caso es .bash_alias_oso.

Esos atajos que crees con el comando ‘‘alias’’ te ayudarán a ahorrar tiempo, cuando estés realizando trabajos en la terminal de tu PC o si estás administrando un servidos.

Bueno compañeros de #Linux, hasta llegó esta curso y espero que el mismo sea de utilidad para todos los que están iniciando en este maravilloso mundo del software libre.

Cualquier duda por favor la dejan en sus comentarios.

Mis mejores deseos para todos y gracias por leerme.


Paginas Consultadas: 1, 2


cintillo_hive.png


cierre__post_Peakd.png


To read English


Screenshot


cintillo_hive.png


Greetings #Lunuxeros, members of the #Linux&Free Software community and the entire #Linux community in #Hive, welcome to a new post of #Fridaysdescritorio.

This Friday, is the last, part of the course, about the handling and use of the Terminal. In this part of the course we are going to learn what it is and how to use the ‘alias’ command. Already with this command, we can make abbreviations in the commands we use in the terminal, which will allow us to optimize our work when we are in the #Linux console.

We finish with this command, because with what we have learned in the workshop, we know all the basic processes that will allow us to work safely and effectively in the #Linux terminal. It would remain later, that one continues to learn and deepen, but the advantage is that we will do it with a good foundation, which will allow us to move forward safely.

It is good to remember, before continuing, that we should always exercise what we are learning so that we do not forget and thus safely advance in the use of our #Linux system.


What is the ‘alias" command?


When we talk about the "alias" command we are talking about a tool that will allow us to create a connection to a longer command. This will allow us to shorten our commands in the terminal, through the creation of a shorter shortcut that we create.

That is, we will make a shortcut, which is a term that computer science refers to a shortcut, or a quick and direct access. You can read more about this term here

Another point that we must take into account with the "alias" command is that normally, the shortcut that we create, will work as long as the open terminal session lasts, once it closes, the creation of the abbreviation that we made is lost.

However, there is a way to make it fixed that we will see a little later.


How is the ‘alias" command used?


The "alias" command has a sitaxis or way of being written that is as follows:

alias abbreviation="The command or group of commands that you want to replace with the alias"

Example: suppose that I want to make an "alias‘ with the command ’ls‘ in that ’alias" I want to put that the command gives me the list in the form of a list and lists all the files. We would do it like this:

alias lc="ls -l -a"

See images.


Screenshot.


Screenshot.


How to make the abbreviations made with "alias" fixed?


We must remember that we can make different abbreviations with the same command and with different commands, we will do this according to our needs in the terminal.

I'm going to give another example, we already saw above how to put an abbreviation with "alias‘ in the ’ls" command, but we will make one to update the repositories and check for package updates.

It would be like this: alias pp="sudo apt update && sudo apt upgrade"
But now, I want the abbreviation "pp’ to be fixed to update the packages whenever I want.
To do this we must do the following:

  • Let's create a file, we can do it with any text editor, I use "xed" that comes with Linux Mint. And we give him a name that will help us locate him I gave him.bash_alias_oso

see images


Screenshot.


Screenshot.


- Now we place all the "aliases" that we want, I will in principle only place the two examples.

See image


Screenshot.


  • Now we save and close the file.

  • Now we are going to our personal folder if we want to do it in graphic mode and we give the keys Ctrl + h, so that it shows us all our hidden directories and we look for the directory that we created in my case.bash_alias_oso, we open it and place the following text:

if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
if

see images.


Screenshot.


Screenshot.


  • Now we save and close the file.

  • Then open the terminal and read the file with the following command:
    source ~/.bash_alias_oso (in the case of you you would be source ~/.bash_ + the name given to the directory)

  • Finally we tested our abbreviations made with the ‘alias" command and we will see that they work well.

  • Be careful, remember that in order for the ‘aliases’ command you created to be activated and you can use them, you must place the ‘source ~/" command.bash" plus the name of the folder where you created the aliases.

See image


Screenshot.


Remember that if you are doing a lot of work in the terminal and you want to create several more aliases, you just do them, check that they work well in the terminal and then put it in the file you created, which in my case is .bash_alias_oso.

Those shortcuts that you create with the "alias" command will help you save time, when you are doing work on your PC terminal or if you are managing a server.

Well #Linux colleagues, this course has even arrived and I hope that it will be useful for everyone who is starting out in this wonderful world of free software.

Any questions please leave them in your comments.

Best wishes to all and thanks for reading.


Pages Consulted: 1 , 2


cintillo_hive.png


cierre__post_Peakd.png



0
0
0.000
3 comments
avatar

Thanks for your contribution to the STEMsocial community. Feel free to join us on discord to get to know the rest of us!

Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).

You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support. 
 

0
0
0.000
avatar

Excelente aporta a la comunidad tu Curso de Manejo de Terminal. Publicaciones como esta dan a conocer nuestro sistema operativo favorito. Con la unión de todos los interesados en promoverlo, seguro llegaremos lejos. Feliz dìa

0
0
0.000