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]
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.
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.
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
6. Jump to a previously visited directory ‘/var/www‘.
$ j www
7. Jump to the previously visited parent/child directory ‘/home/avi/autojump-test/b‘ without typing a sub-directory name.
$ jc b
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
You can also open a child directory in a file manager.
$ jco c
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
~/.local/share/autojump/
. Don’t overwrite these files, or else you may lose all your stats.$ ls -l ~/.local/share/autojump/
10. You may seek help if required simply as:
$ j --help
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.
And it’s totally unnecessary to do `
apt-get dist-upgrade
`, just do: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.
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.@Vince,
Thanks for finding this tool useful, have you seen any output with
j
? bothj
and autojump command gives the same output? could you share?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.
@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?
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“.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.
I had to use
rpm -ql autojump
to see whereautojump.sh
is located because it seems like the path that is given in the post for the location ofautojump.sh
is wrong. Or search forautojump.sh
and add those commands at the end of the post.Notable fact: bash has a simplistic directory bookmarking feature.
Defining the first two lines in
.bashrc
allows directory jumping:Here’s a screencast about it:
nevertheless, autojump is a cool productivity tool.
It gives this error when I try to install it.
@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.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
orautojump
, it executes but not going to the directory.@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.
It’s a good command. I think it will be better if integrate some functions from pushd/popd.
Agree! Chang Limin.