You can create a shortcut to frequently accessed directories by adding them to the
CDPATH environment variable. So, say I frequently access /var/www/html/. Instead of typing
cd /var/www/html, I can add /var/www/ to
CDPATH and then I only have to type
Open ~/.bashrc (or ~/.bash_profile) and add the following line with your frequently used directories separated with a colon (similar to
Here’s an example usage:
dhildreth@hostname:~> export CDPATH=$CDPATH:/var/www/ dhildreth@hostname:~> cd html /var/www/html dhildreth@hostname:html>
There’s one caveat to using this that I’ve ran into in the past: if you are working with Makefiles and building c/c++ apps, this can potentially confuse the Makefile script. So, if you suddenly can’t build your project after adding this variable, try removing it.