How to Create and Delete BASH Profile Aliases

Adam Towers
Sep 4, 2018 · 1 min read

Suppose you have a project folder deeply nested inside a tree of directories on your machine and you have to type in a long command line script like this to get to it:

cd Documents/Development/Freelance/my-freelance-project/my-freelance-project-front-end

We can easily make that much easier to enter using aliases. Thankfully, they are easy to set up (and remove).

Create an alias

To save the above as an aliases, simply open your command line and type:

alias freelance=”cd Documents/Development/Freelance/my-freelance-project/my-freelance-project-front-end”

Now all you have to do is type freelance in your terminal and you’re already saving yourself the trouble!

Note: If you created an alias for a cd command, make sure you include the full path starting with ~/ so that the alias works no matter what directory you’re currently located in.

Note 2: Depending on your terminal emulator, you may need to restart or type source ~/.bash_profile to start using the alias.

Delete an alias

This is even easier. To delete the alias above, all I need to do is:

unalias freelance

Fun fact: You can run this command from any directory and it’ll work.

View all of defined aliases

To see a list of all the alias that have been created in your bash profile, all you need to do is type in:

alias

And BAM, you have a readout of all the aliases that are currently defined.

Adam Towers

Written by

Full Stack Web Developer with a background in Graphic Design.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade