Member-only story

How to easily see your current Bash aliases, functions and variables

Leo Gutiérrez
2 min readSep 26, 2020

--

In this short post I will show you multiple ways to list your Bash aliases, functions and environmental variables. Sometimes you just need what variables you have in your current environment, there are several ways you can list your variables.

printenv

As the man page and its name, this command can help you to list and print all your environmental variables. You can provide an environmental variable and it will show you the exact value.

set

This command (set is actually a shell builtin) is really powerful, executed without arguments will list all your environmental variables and functions.

env

Executed without arguments, env will print the current environment, that is your current environmental variables.

declare

declare is a shell builtin. Executed without arguments will list your current functions. If you use the -p option, it will list everything, environmental variables (with its attributes….) and functions.

alias

alias is another shell builtin, if you need to check your current aliases, just run the alias in the command line and it will show you all your aliases. You can also provide an argument, the alias name and it will show you the declaration, example:

0 🐧 [18:32]leo@lein ~ $ alias grep
alias grep='grep --color=auto'
0 🐧 [18:32]leo@lein ~ $

I am pretty sure there are other ways of doing this natively, if you know other ways of listing your current environment, please let us know in the comments, thank you!

--

--

Leo Gutiérrez
Leo Gutiérrez

Written by Leo Gutiérrez

Hi! I am Leonardo Gutiérrez R., a passionate software developer, I hope you find the content in this blog interesting. I write about IT related stuff.

No responses yet