Use Autojump Advanced Navigation in Linux Examples

This guide intends to teach you to Use autojump Advanced Navigation in Linux with Examples. As a Linux user, you may find that using the cd command to move between directories takes your time. So you can use an alternative way for advanced navigation called autojump. Let’s see the usage of this tool and how you can use it in your Linux server with examples.

What is Autojump in Linux?

It is a great and powerful tool that you can use to navigate between your directories. The autojump tool is the best choice if you have a large number of directories. You can save your time by using this tool instead of the cd command.

In this guide, you will learn to install autojump on your Linux server and start using it with the examples provided for you.

Steps To Install and Use Autojump Advanced Navigation in Linux Examples

To complete this guide, you must have SSH access to your server as a root or non-root user with udo privileges. To do this, you can visit the Orcacore website and check for the Linux initial server setup guides.

Now follow the steps below to install the autojump tool.

Step 1 – Install Autojump in Linux Terminal

You can install this amazing tool from your Linux default package manager and from the source. To do this, follow the steps below.

Install Autojump from the Linux Package Manager

The autojump packages are available in most Linux default repositories.

To install it on Ubuntu and Debian-based distros, you can use the following commands:

# sudo apt update && sudo apt upgrade -y
# sudo apt install autojump -y

On RHEL-based distros like Centos, AlmaLinux, and Rocky Linux, you must enable the Epel repository and then install autojump. To do this, run the following commands:

# sudo dnf update -y && sudo dnf upgrade -y
# sudo dnf install epel-release -y
# sudo dnf install autojump -y

Installing Autojump in Linux from the source

You can also install Autojump from the source in your Linux servers. You just need to install Git on your server and follow the steps below.

# sudo apt install git    #debian-based distros
# sudo dnf install git    #rhel-based distros

Clone autojump from GitHub:

sudo git clone git://github.com/wting/autojump.git

Then, navigate to your Autojump advanced directory in Linux:

cd autojump

Next, make your file executable and run the script to install autojump:

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

When your installation is completed, you can verify it by checking its version:

autojump -v
Output
autojump v22.5.3

Step 2 – Enable and Activate Autojump on Linux

At this point, you should activate the autojump tool manually. To do this, you can use the following command to activate this tool in your Bash shell:

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

Step 3 – Advanced Navigation with Autojump in Linux

Autojump will keep a history of your visited directories in the Linux command line. It only jumps into the directories you use the cd command for them. Here to show you its usage, we did the following commands:

# cd /var/www
# cd
# mkdir auto-test/
# cd  auto-test/
# cd
# mkdir auto-test/aj/
# cd auto-test/aj/
# cd
# mkdir auto-test/aj1/
# cd auto-test/aj1/
# cd

At this point, you can follow the steps below to start using the autojump command.

Step 4 – Use Autojump Command in Linux Terminal

At this point, you can use the autojump command or j in the Linux terminal to start using it for navigation. For example, to check the version, you can use the command below:

# j -v
Or
# autojump -v

Check Autojump Stats in Linux

To get your stats, you can use the -s option with the autojump command in the Linux terminal:

j -s
Output
10.0:   /var/www
10.0:   /root/auto-test
10.0:   /root/auto-test/aj
10.0:   /root/auto-test/aj1
14.1:   /usr/share/autojump
________________________________________

54:      total weight
5:       number of entries
0.00:    current directory weight

data:    /root/.local/share/autojump/autojump.txt

With this option, you can check all the visited directories with autojump advanced navigation.

Start Jumping with Autojump

For example, we can jump to our /var/www visited directory only by typing the first letter of the directory:

j w
Output
/var/www

It will switch the directory to the /var/www.

Also, you can jump to a directory without typing the sub-directory name. For example, if we want to navigate to the /root/auto-test/aj directory, we should simply type:

jc a
Output
/root/auto-test/aj

Open a File manager with Autojump

You can simply open a file manager with the autojump command in Linux with the o option. For example:

jo www

Also, you can open a child directory in a file manager. For example:

jco aj1

Other Options of Autojump

To get more information and help with the Autojump advanced navigation command, you can run the command below:

j -h
Output
usage: autojump [-h] [-a DIRECTORY] [-i [WEIGHT]] [-d [WEIGHT]] [--complete]
                [--purge] [-s] [-v]
                [DIRECTORY ...]

Automatically jump to directory passed as an argument.

positional arguments:
  DIRECTORY             directory to jump to

optional arguments:
  -h, --help            show this help message and exit
  -a DIRECTORY, --add DIRECTORY
                        add path
  -i [WEIGHT], --increase [WEIGHT]
                        increase current directory weight
  -d [WEIGHT], --decrease [WEIGHT]
                        decrease current directory weight
  --complete            used for tab completion
  --purge               remove non-existent paths from database
  -s, --stat            show database entries and their key weights
  -v, --version         show version information

Please see autojump(1) man pages for full documentation.

Also, you can read the man page:

man autojump
Output
autojump(1)                                                        autojump(1)

   NAME
       autojump - a faster way to navigate your filesystem

   DESCRIPTION
       autojump  is  a  faster  way  to navigate your filesystem.  It works by
       maintaining a database of the directories you use  the  most  from  the
       command line.

       Directories must be visited first before they can be jumped to.

   USAGE
       j  is  a convenience wrapper function around autojump.  Any option that
       can be used with autojump can be used with j and vice versa.

       • Jump To A Directory That Contains foo:

                j foo

       • Jump To A Child Directory:

         Sometimes it's convenient to jump to a child directory (sub-directory
...

Conclusion

At this point, you have learned to install and use Autojump Advanced Navigation in Linux with some basic Examples. This tool works based on your cd command history and helps you to navigate more quickly between your directories. Hope you enjoy it.

You may be interested in these articles:

Install Froxlor Control Panel on RHEL 8

Open Crontab in Nano Editor

Create and Run Shell Scripting in Linux

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Stay informed and not overwhelmed, subscribe now!