Variables de entorno y alias
Gestione y personalice su entorno de shell mediante variables de entorno y alias de comandos.
Variables de entorno y alias es una lección gratuita de Linux Command Line Mastery en CoddyKit. Esta es la lección 2 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Linux Command Line Mastery, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Linux Command Line Mastery incluye 4 lecciones en total.
Partes de esta lección aún no han sido traducidas y se muestran en inglés.
Your Shell's Environment
Welcome! In this lesson, we'll dive into how your Linux shell keeps track of important information. This 'environment' helps your commands run smoothly.
Think of it as your shell's personal workspace, full of settings and shortcuts.
Meet Environment Variables
Environment variables are dynamic named values that store information used by the shell and other programs. They let you customize how your system behaves.
- They are like temporary storage for your shell.
- They can hold paths, user settings, and more.
- Other programs can read these variables to know how to act.
Checking Current Variables
You can see all active environment variables using the printenv command. To view a specific variable, use echo $VARIABLE_NAME.
The dollar sign $ before a variable name tells the shell to show its value.
printenv | head -n 3
echo $HOMEImportant System Variables
Two very common and important environment variables are PATH and HOME:
PATH: A list of directories where the shell looks for executable commands. When you typels, the shell checks these directories.HOME: The absolute path to your home directory. This is where your personal files and settings are usually stored.
Setting Temporary Variables
You can create your own environment variables for the current shell session. Just assign a value to a name:
VARIABLE_NAME="value"
Note that there are no spaces around the = sign. These variables are temporary and disappear when you close the terminal.
MY_MESSAGE="Hello CoddyKit"
echo $MY_MESSAGE
# This variable only exists in this shellMaking Variables Global with 'export'
Variables set directly are only available in the current shell. To make them available to any sub-processes (like scripts or other commands you run from your current shell), you need to export them.
export GLOBAL_VAR="I am global"
bash -c 'echo $GLOBAL_VAR'
# Without export, 'bash -c' wouldn't see it.Introducing Command Aliases
Command aliases are custom shortcuts for longer commands or sequences of commands. They save you typing and can even fix common typos.
- They personalize your command-line experience.
- You define a short name that expands to a longer command.
- Great for frequently used, complex commands.
Creating Quick Shortcuts
To create an alias, use the alias command followed by name='command'. Like variables, these are temporary and last only for the current shell session.
A common example is aliasing ls -alF to ll for a detailed file listing.
alias ll='ls -alF'
ll
# Now 'll' runs 'ls -alF'Listing and Removing Aliases
To see all aliases currently active in your shell, simply type alias without any arguments. If you want to remove an alias, use the unalias command.
alias
alias c='clear'
alias
unalias c
aliasCheck Your Understanding
You've learned about environment variables and aliases. Let's test your knowledge!
Consider the following:
MY_VAR="Test"
export MY_VAR
Which statement is true after running these commands?
Lesson Summary
Great job! You've successfully explored environment variables and aliases.
- Environment variables store key-value pairs for your shell and programs.
- Use
echo $VARto see a variable's value andprintenvto list them all. exportmakes variables available to sub-processes.- Aliases are custom shortcuts for commands, created with
alias name='command'. - Both are temporary by default, lasting only for the current shell session.
Next, you'll learn how to make these customizations permanent!
Preguntas frecuentes
¿La lección «Variables de entorno y alias» es gratis?
Sí — el texto completo de «Variables de entorno y alias» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Linux Command Line Mastery, actualiza a CoddyKit PRO. El curso de Linux Command Line Mastery incluye 4 lecciones en total.
¿Qué aprenderé en «Variables de entorno y alias»?
Gestione y personalice su entorno de shell mediante variables de entorno y alias de comandos. Practicas Linux Command Line Mastery con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.
¿Necesito experiencia previa para empezar Linux Command Line Mastery?
No se requiere experiencia previa. Linux Command Line Mastery en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 2 de 4.
¿Cuánto tiempo toma la lección «Variables de entorno y alias»?
La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.
¿Puedo escribir y ejecutar código en esta lección de Linux Command Line Mastery?
Sí. Cada lección de Linux Command Line Mastery incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.
Todas las lecciones de este curso
- Fundamentos de Git desde la línea de comandos
- Variables de entorno y alias
- Configuración del shell: `.bashrc`, `.zshrc`, `.profile`
- Ramificación y merge con Git desde la línea de comandos