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-releasecommand.
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.
jis 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
$ 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.
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.