Alex Sarmiento
ES / EN

1. The .bashrc file

When working with Linux, you often need to configure aliases, environment variables, or customize your prompt. If you run these commands in the terminal, the changes are lost when you close the session. To make them permanent, we use the .bashrc file.

This file is located in your home directory (~/.bashrc) and runs every time you open a new interactive terminal.

1.1 Edit the .bashrc

To edit it, use your favorite editor:

nano ~/.bashrc

You can add your customizations at the end of the file.

1.2 Useful aliases

Aliases are shortcuts for long commands. Here are some useful examples:

# Update the system with a single word
alias update='sudo apt update && sudo apt upgrade -y'

# Quick navigation
alias ..='cd ..'
alias ...='cd ../..'
alias ll='ls -alF'

2. Environment Variables

Environment variables store information used by programs and the shell.

2.1 Define a variable

To define a variable temporarily:

export MY_VARIABLE="value"

To make it permanent, add the above line to your .bashrc.

2.2 View variables

You can view all variables with the env command or print a specific one with echo:

echo $HOME
echo $PATH

3. Apply changes

After editing your .bashrc, the changes are not immediately applied in the current terminal. To reload the configuration without closing and opening the terminal, use the source command:

source ~/.bashrc

Or its shorthand:

. ~/.bashrc

Now your configuration is ready and will persist between sessions!