Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

In the Ubuntu terminal I find myself spending considerable time to switch to a particular directory every time the computer starts up. Is there some way I can make this process easier? Is there some hotkey or some quick directory change that I can use (like speed dial on a phone)?

    cd 1:Changes to saved directory one
share|improve this question
add comment

7 Answers

up vote 6 down vote accepted

There are two options:

  1. If you want to be in a specific directory everyt time you open a bash terminal, edit your ~/.bashrc file and just add the line cd Directory, for example cd ~/Desktop.

  2. If you want to have several short-cuts, you can always use global variables, which you can set in your ~/.bashrc file as follows export a=/tmp and then you would be able to do cd $a which would bring you to /tmp.

Remember that after editing your .bashrc file you have to restart the terminal or open a new one.

share|improve this answer
Second one works well. Thanks for the help –  Developer Android Dec 7 '12 at 9:42
To avoid restarting the terminal you can use source ~/.bashrc or, shorter, . ~/.bashrc. –  Gerhard Burger Dec 8 '12 at 9:33
add comment

Also have a look at autojump, it builds a database with previously visited directories and then you can jump to it. So for instance you have


then if you have visited it once you can jump to it by

j workstuff

or even

j stuff

because it also works with partial matches. If more than one directory matches you jump to the one that is most visited, if this is not the one you wanted, then repeat the command to go to the second.

However it gets better! If you also have the directory


and you do

j stuff 

and then TabTabTab you get (in the order of most visited)

$ j stuff__

and then you can just press the number of the directory you want!

To install you can just use sudo apt-get install autojump and then you need to add

source /usr/share/autojump/autojump.bash

to your ~/.bashrc.

More information here: https://github.com/joelthelion/autojump#name

share|improve this answer
That seems very interesting. Thanks a lot –  Developer Android Dec 7 '12 at 10:25
crtl + r in a terminal also looks for "partial matches" in previous commands. Really handy as well. –  Dan Dec 7 '12 at 13:03
add comment

Bash aliases are useful for creating short-cuts to commonly run commands.

  • In ~/.bashrc, add a line similar to the following to create the alias:

    alias jump1='cd /long/path/name/that/is/frequently/used'
  • Close and open the terminal again, or run source ~/.bashrc.

  • From now on, you can just run jump1 to execute that long cd command.

See also:

share|improve this answer
add comment

Even though there are some good answers already, I thought I'd mention for completeness the old pushd and popd Bash builtins with allow you to move very quickly between directories in deep paths in your filesystem. In contrast to the autojump bookmarks mentioned by burger.ga, the directory stack created by using pushd is only temporary.

As the GNU manual notes, pushd and popd are Bash builtins used to construct a temporary directory stack that is a

list of recently-visited directories. The pushd builtin adds directories to the stack as it changes the current directory, and the popd builtin removes specified directories from the stack and changes the current directory to the directory removed. The dirs builtin displays the contents of the directory stack.

It takes a bit of getting used to, but there are plenty of useful tutorials out there at this blog and this this site for example. There are no separate manpages for the commands, as they are included in the Bash manpage, but for quick reference you can view the GNU Bash page.

The clearest explanation is in this very useful article and is exactly the way I use pushd and popd:

Firstly, use dirs or dirs -l to list directories on the stack and dirs -c to clear the stack.

In a sense you bookmark the location where you want to return by entering

pushd /home/mike/Pictures/Canon/2012_07_01

and then you can add more directories to the stack, so you get a dirs listing as below, which includes 3 designated folders and your ~ home folder:

~/Downloads/folder/interest ~/Music/artist/album ~ ~/Pictures/Canon/2012_07_01

You actually don't need to use popd straightaway as that removes directories from the stack; the best thing to do is to use pushd to rotate the stack, so that you can keep switching between the directories and order them as you want. For more on that useful stack rotation see the Bash manpage.

If you have exactly the stack arrangement as the above dirs listing shows, pushd +3 switches you to the specific Pictures folder and places that on top of the stack (it is +3 and not +4 as you do not count your ~ in the directory stack):

pushd +3
~/Pictures/Canon/2012_07_01 ~/Downloads/folder/interest ~/Music/artist/album ~

So the prompt reads,


You can keep on doing this without removing them from the stack, although any folders you cd to, other than those added to the directory stack with pushd, will alter your directory stack.

Once you have the directory stack arranged in the order you want, you can use popd to quickly cycle through the directories and then return to the home folder; for example, from Pictures we can return to Downloads:

~/Downloads/folder/interest ~/Music/artist/album ~

and the prompt reads


In general the beauty of this is that you can set up the directory stack and the order of items within it with pushd and then, say you have three files to edit in each of those directories, you can return instantly to each one with popd while removing them from the directory stack. Then with your last popd you will return to ~. It becomes particularly useful when you have particularly deep directories and can use it to set up the directory stack to quickly move between them.

In addition, this question contains some tips that you might find useful when working on the command-line:

share|improve this answer
add comment

Even though there exists some command line way to do it faster, I would personnally recommand using a Nautilus extension called nautilus-open-terminal.

First install the package nautilus-open-terminal and bookmarks your favorite folders with Nautilus. On Nautilus 3.6.*, you'll have to go into the gear menu and select Bookmark this Location.

enter image description here

Then use Nautilus bookmarks to go faster in your favorite directories, and just right click on an empty space and select Open in Terminal.

enter image description here

Now you can have both command line and file manager quick access to your favorite directories.

share|improve this answer
The original poster is trying to work from the terminal and it is often quicker to work from the terminal. –  haziz Dec 8 '12 at 6:28
@haziz: Yes, but AskUbuntu questions and answers should be useful not only to the OP, but specially for all people who found this in the web. This is a valuable answer for me. –  Javier Rivera Dec 8 '12 at 13:00
add comment

You can place an alias in your .bashrc file (or the config file for your favorite shell-they are usually in your home directory):

alias cd1="cd directory/directory/my_destination/"

A useful info link about using aliases in bash is here.

share|improve this answer
add comment

I use DirB (Directory Bookmarks) to do this. Very nice! http://www.linuxjournal.com/article/10585

I have modified mine to suit my taste and be easier to use and clearer though.

share|improve this answer
Welcome to Ask Ubuntu! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. –  fossfreedom Dec 13 '12 at 21:52
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.