Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Having some problems googling this one because I'm not sure what the search term is. Shell scripting or terminal feature. What is the best way to streamline access to frequently used directories. Normally when I start a terminal it defaults to my home directory but sometimes I ike to open several terminal windows, the problem is I'm typing the cd /.../directory in each one multiple times and I need a way to not have to do this. What is the best way or just provide the search terms I could use to read about it online. Thank you

share|improve this question

migrated from Nov 11 '11 at 3:08

This question came from our site for professional and enthusiast programmers.

create alias for each directory that you very often use. Also use cd - to go back to last directory that you accessed – Prince John Wesley Nov 10 '11 at 17:04
up vote 5 down vote accepted

Create a symbolic link in your home directory:

$ ln -s path/to/a/really/deeply/nested/director/my-project ~/my-project

$ cd ~/my-project
share|improve this answer

Add a variable in your .bashrc:


to use:

share|improve this answer

Set the CDPATH variable: it contains additional directories to be searched when you run cd.

share|improve this answer

You can also take advantage of CDPATH variable.

And you could define a bash function in your $HOME/.bashrc like

 # in file ~/.bashrc
 function work() {
    cd $HOME/path/to/a/really/deeply/nested/director/my-project

And recent bash or even better zsh may permit you things like

 cd **/my-project

Assuming you have only one deeply nested my-project/ directory in all your tree hierarchy. The ** is doing the equivalent of a find so can be slow.

share|improve this answer

You could use a bookmarks for the shell, e.g.

share|improve this answer

Add an alias in your .bashrc

alias myproject="cd path/to/a/really/deeply/nested/director/my-project"

to use:

$ myproject
share|improve this answer

You can also try autojump.

It is like cd command but with the ability to learn. It maintains a database of directories you visit and assign weight to each entry.

Later you can use j foo to jump to a directory that contains foo in its name. If more than few directories have foo, it will show you a list of matches from where you can select your desired directory.

share|improve this answer

The author of CDPATH recommends to export CDPATH to the environment. Please keep in mind that there is a strong chance that this will subtly break shell scripts that expect directories to be in one specific place. A remedy is to put CDPATH into ~/.bashrc and not export it. Your ~/.bashrc would look like this:


Note that sourced shell scripts will still pick up CDPATH in this case. autojump is certainly a much safer alternative and more convenient to use than CDPATH.

share|improve this answer

anc is designed exactly for this use case.

Here's an excerpt from the

# make the current directory the default anchor:
$ anc s

# go to /etc, then /, then /usr/local and then back to the default anchor:
$ cd /etc; cd ..; cd usr/local; anc

# go back to /usr/local :
$ anc b

# add another anchor:
$ anc a $HOME/test

# view the list of anchors (the default one has the asterisk):
$ anc l
(0) /path/to/first/anchor *
(1) /home/usr/test

# jump to the anchor we just added:
# by using its anchor number
$ anc 1
# or by jumping to the last anchor in the list
$ anc -1

# add multiple anchors:
$ anc a $HOME/projects/first $HOME/projects/second $HOME/documents/first

# use text matching to jump to $HOME/projects/first
$ anc pro fir

# use text matching to jump to $HOME/documents/first
$ anc doc fir

# add anchor and jump to it using an absolute path
$ anc /etc
# is the same as
$ anc a /etc; anc -1

# add anchor and jump to it using a relative path
$ anc ./X11 #note that "./" is required for relative paths
# is the same as
$ anc a X11; anc -1

# using wildcards you can add many anchors at once
$ anc a $HOME/projects/*

# use shell completion to see a list of matching anchors
# and select the one you want to jump to directly
$ anc pro[TAB]

Full disclosure: I'm the author of anc.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .