Jump! Quick directory change at the command line

Database Based

You can easily jump into directories that autojump keeps in its database using the j wrapper. For example, j Dow would take you to the ~/Downloads directory. In the same way, j loa also takes you there. The depth of the directory hierarchy is not important; the main thing is that you visited the desired directory at least once using cd.

If you want to switch to your file manager for a better overview, jo Dow opens the directory for Plasma in Dolphin or for Gnome in Nautilus (Figure 2). If you just enter j, the command jumps to the most frequently visited directory, for which Autojump uses internal weighting.

Figure 2: If you have lost track at the command line, autojump will also open the desired directory in the file manager.

If you call the content of the database with j --stat, you will see different numbers in front of the respective paths, for example:

22.4: /home/devil/Downloads/piwik

This sequence of digits is the internal weighting (Figure 3). As an example, the following directories are in the database:


Figure 3: The numbers in the database are used for internal weighting and state which directories were visited and how often.

If you enter j in, high weighting causes autojump to switch to /home/user/mail/inbox/, whereas j w in would be the correct command to access the lower weighted directory. You can use the --increase (-i) and --decrease (-d) parameters to change the weighting, and j --help for additional information about syntax.

Alternatively, if you have several similar directories, you can display the numbered entries by means of tab-based autocompletion and then select the corresponding entry by number.

A helpful tip when using autojump: Sometimes the database suddenly empties, which can be extremely annoying, because you then have to start indexing from scratch. Sometimes it is better to back up the database manually.


Fasd [4], the final tool covered in this article, was inspired by autojump. However, the software exceeds its role model: Fasd no longer restricts the navigation options to the directory tree, and it also indexes the data. Fasd works with the Ash, Bash, Zsh, mksh, pdksh, dash, and BusyBox shells under Linux, as well as /bin/sh in FreeBSD 9 and OpenBSD.

Fasd lets you open files by entering just a few characters in Vim or your default editor. You can view PDFs or play movies and music with MPlayer or your favorite player. The letters in the Fasd acronym stand for predefined aliases that process different types of data.

When you enter f, the tool shows you the visited files, including their weighting. Entering d provides the same result for the directories, and a lists both. zz takes you to a view in which you select an entry by the prefixed number (Figure 4).

Figure 4: In Fasd, you can select the desired directory using z and a few characters. You can select from the database by entering zz.

Defining additional aliases lets you open various files: for example, PDFs (Figure 5). In turn, you can create the following proxy in .bashrc:

alias o='a -e xdg-open'
Figure 5: Defining additional aliases extends Fasd to display PDFs and other formats.

Now source the file, as shown in Listings 2 and 3. The following also applies: Like autojump, Fasd only detects objects that have already been indexed.

Movies and music also can be started with just a few keystrokes. For this to work, enter

alias m='f -e mplayer'

in .bashrc. Alternatively, use a different player or change the m call switch to another. Then, simply start the movies or music using m<part of title>.

Like autojump, Fasd also lets you use letters from the middle of the name. The aliases' structure is simple: -e stands for execute. For files, select f; for directories, d. If the alias includes both, as with xdg-open [5], select a. On GitHub, the project provides an overview of the tool's many other possibilities.


All three tools presented in this article have one thing in common: They do not run in drop-down terminals, such as Yakuake or Guake, just in consoles or terminals. However, you will not read this anywhere, which led to me occasionally doubting the tools' capabilities in the lab. All three helpers are meaningful, and they build on each other.

If you do not constantly work at the command line, bd makes it easy to navigate without having to learn something new. Autojump offers much more and jumps into directories in random directions. This suits the workflow of users who frequently work on servers and like to handle administrative work at the command line. After the introduction phase, autojump saves some time here.

Fasd expands the feature set again, because it also indexes files and thus takes control of all the files on the computer. It also offers professional options to further customize the approach to suit your own needs.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Command Line: autojump

    Autojump is a mature and widely available command-line tool for navigating your directory structure. We show you how it works.

  • Beyond cd

    For decades, cd has been a Linux workhorse, but modern drives sometimes call for more efficient navigation tools. Read on for alternatives for advanced command-line navigation.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More