Autojump – Quickly Navigate Directories and Linux File System

Those Linux users who mainly work with Linux command Line via console/terminal feels the real power of Linux. However, it may sometimes be painful to navigate inside the Linux Hierarchical file system, especially for newbies.

There is a Linux command-line utility called autojump, which was written in Python by Joël Schaerer and now maintained by +William Ting, which is an advanced version of the cd command.

Autojump is a command-line tool that offers a faster way to navigate the Linux file system by keeping the database of directories that the user visits frequently. It works by keeping an eye on the directories that the user navigates and then assigning importance to each directory based on how regularly the user visits.

This allows users to quickly jump to a frequently visited directory. Autojump navigates to the required directory more quickly as compared to the traditional cd command.

Features of autojump

  • Free and open source application and distributed under GPL V3
  • A self-learning utility that learns from the user’s navigation habit.
  • Faster navigation. No need to include the subdirectories’ names.
  • Available in the repository to be downloaded for most of the standard Linux distributions including Debian, Ubuntu, Mint, Arch, Gentoo, Slackware, CentOS, RedHat, and Fedora.
  • Available for other platforms as well, like OS X (Using Homebrew) and Windows (enabled by Clink)
  • Using autojump you may jump to any specific directory or to a child directory. Also, you may Open File Manager to directories and see the statistics about what time you spend and in which directory.

Step 1: Do a Full System Update

1. Do a system Update/Upgrade as a root user to ensure you have the latest version of Python installed.

# apt-get update && apt-get upgrade && apt-get dist-upgrade [APT based systems]
# yum update && yum upgrade [YUM based systems]
# dnf update && dnf upgrade [DNF based systems]
It is important to note here that, on YUM or DNF-based systems, update and upgrade perform the same things and most of the time interchangeable, unlike APT-based systems.

Step 2: Download and Install Autojump

2. As stated above, autojump is already available in the repositories of most Linux distributions. You may just install it using the Package Manager.

On RedHat-based distributions, you need to enable the EPEL repository by running yum install epel-release command.

Install Autojump from Repositories

$ sudo apt install autojump      [On Debian, Ubuntu and Mint]
$ sudo yum install autojump       [On RHEL/CentOS/Fedora and Rocky/AlmaLinux]
$ sudo emerge -a autojump        [On Gentoo Linux]
$ sudo apk add autojump          [On Alpine Linux]
$ sudo pacman -S autojump        [On Arch Linux]
$ sudo zypper install autojump   [On OpenSUSE]    

However, if you want to install autojump from the source, you need to clone the source code and execute the Python script, as:

Installing Autojum from Source

Install git, if not installed, which is required to clone the autojump git repository.

$ sudo apt install git      [On Debian, Ubuntu and Mint]
$ sudo yum install git      [On RHEL/CentOS/Fedora and Rocky/AlmaLinux]
$ sudo emerge -a git        [On Gentoo Linux]
$ sudo apk add git          [On Alpine Linux]
$ sudo pacman -S git        [On Arch Linux]
$ sudo zypper install git   [On OpenSUSE]  

Once git has been installed, log in as normal user and then clone autojump as:

$ git clone git://github.com/joelthelion/autojump.git

Next, switch to the downloaded directory using the cd command.

$ cd autojump

Now, make the script file executable and run the install script as the root user.

# chmod 755 install.py
# ./install.py

Step 3: Autojump Configuration

3. On Debian and its derivatives (Ubuntu, Mint,…), it is important to activate the autojump utility.

To activate the autojump utility temporarily, i.e., effective till you close the current session, or open a new session, you need to run the following commands as a normal user:

$ source /usr/share/autojump/autojump.sh on startup
OR
$ source /usr/share/autojump/autojump.bash on startup

To permanently add activation to the BASH shell, you need to run the below command.

$ echo '. /usr/share/autojump/autojump.sh' >> ~/.bashrc
Or
$ echo '. /usr/share/autojump/autojump.bash' >> ~/.bashrc

Step 4: Quickly Change Linux Directory Using Autojump

4. As said earlier, autojump will jump to only those directories which have been cd earlier. So before we start testing we are going to ‘cd‘ a few directories and create a few as well.

Here is what I did.

$ cd
$ cd
$ cd Desktop/
$ cd
$ cd Documents/
$ cd
$ cd Downloads/
$ cd
$ cd Music/
$ cd
$ cd Pictures/
$ cd
$ cd Public/
$ cd
$ cd Templates
$ cd
$ cd /var/www/
$ cd
$ mkdir autojump-test/
$ cd
$ mkdir autojump-test/a/ && cd autojump-test/a/
$ cd
$ mkdir autojump-test/b/ && cd autojump-test/b/
$ cd
$ mkdir autojump-test/c/ && cd autojump-test/c/
$ cd

Now we have a cd to the above directory and created a few directories for testing, we are ready to go.

The usage of j is a wrapper around autojump. You may use j in place of the autojump command and vice versa.

5. Check the version of installed autojump using -v option.

$ j -v
or
$ autojump -v
Check Autojump Version
Check Autojump Version

6. Jump to a previously visited directory ‘/var/www‘.

$ j www
Jump To Directory
Jump To Directory

7. Jump to the previously visited parent/child directory ‘/home/avi/autojump-test/b‘ without typing a sub-directory name.

$ jc b
Jump to Child Directory
Jump to Child Directory

8. You can open a file manager that says GNOME Nautilus from the command-line, instead of jumping to a directory using the following command.

$ jo www
Jump to Directory
Jump to Directory
Open Directory in File Browser
Open Directory in File Browser

You can also open a child directory in a file manager.

$ jco c
Open Child Directory
Open Child Directory
Open Child Directory in File Browser
Open Child Directory in File Browser

9. Check stats of each folder key weight and overall key weight along with total directory weight. Folder key weight is the representation of the total time spent in that folder. Directory weight is the number of directories in the list.

$ j --stat
Check Directory Statistics
Check Directory Statistics
Tip: The file where autojump stores run log and error log files in the folder ~/.local/share/autojump/. Don’t overwrite these files, or else you may lose all your stats.
$ ls -l ~/.local/share/autojump/
Autojump Logs
Autojump Logs

10. You may seek help if required simply as:

$ j --help
Autojump Help and Options
Autojump Help and Options

How Autojump Works

    • autojump lets you jump to only those directories to which you have already cd. Once you cd to a particular directory, it gets logged into the autojump database and thereafter autojump can work. You can not jump to a directory to which you have not cd, after setting up autojump, no matter what.
    • You can not jump to a directory, the name of which begins with a dash (-). You may consider reading my post on the Manipulation of files and directories that start with '-' or other special characters
    • In BASH Shell autojump keeps track of directories by modifying $PROMPT_COMMAND. It is strictly recommended not to overwrite $PROMPT_COMMAND. If you have to add other Linux commands to existing $PROMPT_COMMAND, append it to the last to existing $APPEND_PROMPT.
Conclusion

autojump is a must utility if you are a command-line user. It eases a lot of things. It is a wonderful utility that will make navigating the Linux directories, fast in the command line. Try it yourself and let me know your valuable feedback in the comments below. Keep Connected, and Keep Sharing. Like and share us and help us get spread.

Ravi Saive
I am an experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

16 thoughts on “Autojump – Quickly Navigate Directories and Linux File System”

  1. And it’s totally unnecessary to do `apt-get dist-upgrade`, just do:

    $ sudo apt install autojump
    OR                                            
    $ sudo apt-get install autojump
    
    Reply
  2. Very awesome, more Linux articles need to learn from you guys. Very well-put-together instructions and I love it, thank you for your work and knowledge base sharing.

    Reply
  3. Love its script but I can’t get it to work with j, it seems to only accept autojump as a command. running on mint 17.3.

    Reply
    • @Vince,

      Thanks for finding this tool useful, have you seen any output with j? both j and autojump command gives the same output? could you share?

      Reply
    • I’ve recently rewritten this tool with Go: github.com/suzaku/shonenjump/

      You only need to download a binary for your platform, so it’s easier to install than the original one written in Python.

      What’s more, it’s much faster.

      Reply
      • @Satoru,

        This is Ravi Saive, the founder of Tecmint.com.

        Thanks for sharing your tool with us, why not you write a review on the same that includes installation as well and send it for publication on TecMint.com?

        Reply
  4. I use Fedora Linux and I installed autojump from the Fedora repository, but the j command is not recognized and the command for bash activation gets “file or command not found“.

    Reply
  5. I am using Fedora Linux and autojump is in the Fedora repository. Version is 21.7.1-4. I have installed autojump but I get the error message “j: command not found” and I tried activate autojump temporarily, but the error message was: “bash: /usr/share/autojump/autojump.sh: file or directory not found“.

    Indeed, I tried to activate autojump permanently, but I got an error message too.

    Reply
    • I had to use rpm -ql autojump to see where autojump.sh is located because it seems like the path that is given in the post for the location of autojump.sh is wrong. Or search for autojump.sh and add those commands at the end of the post.

      Reply
  6. Notable fact: bash has a simplistic directory bookmarking feature.
    Defining the first two lines in .bashrc allows directory jumping:

    ~$ shopt -s cdable_vars
    ~$ export foo=/usr/share/lib/foo/bar
    ~$ cd foo
    /usr/share/lib/foo/bar $
    

    Here’s a screencast about it:

    nevertheless, autojump is a cool productivity tool.

    Reply
  7. It gives this error when I try to install it.

    ./install.py
      File "./install.py", line 40
        with open(os.path.join(etc_dir, 'autojump.sh'), 'a') as f:
                ^
    SyntaxError: invalid syntax
    
    Reply
    • @omipenguin,

      Let me know your Python Version and OS details. You may email me your SSH access at avishek1210[at]gmail.com, for better assistance.

      Reply
  8. I have installed it through yum in Centos 6.3, When I type the command “autojump -v“, it gives me the following error “Unknown command line argument: option -v not recognized“.

    When I run j or autojump, it executes but not going to the directory.

    Reply
    • @balu

      I have already mentioned that autojump learns from you. After installing it, you need to train it. cd to your most frequently visited directories and then it will work.

      However, if you could not do it, you may write me an email @ avishek1210[at]gmail.com with your input commands. your Output Message and your SSH access very clearly, so that I can assist.

      Reply

Got something to say? Join the discussion.

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.