Quickly Go Back To A Specific Parent Directory Using bd Command In Linux
======
Two days back we had written an article about autocd. It’s a builtin shell variable that helps us to **[navigate to inside a directory without cd command][1]**.
If you want to come back to previous directory then you have to type `cd ..`.
If you want to go back to two directories then you have to type `cd ../..`.
It’s normal in Linux but if you want to come back from 9th directory to 3rd directory, then it’s horrible to use cd command.
What will be the solution for this.
Yes, we have a solution in Linux for everything. We can go with bd command, to make easy this kind of situation.
### What Is bd Command?
bd command allow users to quickly go back to a parent directory in Linux instead of typing `cd ../../..` repeatedly.
You can list the contents of a given directory without mentioning the full path `ls `bd Directory_Name``. It supports following other commands such as ls, ln, echo, zip, tar etc..
Also, it allow us to execute a shell file without mentioning the full path `bd p`/shell_file.sh`.
### How To Install bd Command in Linux?
There is no official distribution package for bd except Debian/Ubuntu. Hence, we need to perform manual method.
For **`Debian/Ubuntu`** systems, use **[APT-GET Command][2]** or **[APT Command][3]** to install bd.
```
$ sudo apt install bd
```
For other Linux distributions.
Download the bd executable binary file using **[wget command][4]**.
Even, you no need to type full directory name instead you can type few letters.
```
daygeek@Ubuntu18:/usr/share/icons/Adwaita/256x256/apps$ bd i
/usr/share/icons/
daygeek@Ubuntu18:/usr/share/icons$
```
`Note:` If there are more than one directories with same name up in the hierarchy, bd will take you to the closest. (Not considering the immediate parent.)
If you would like to list a given directory contents then the following format. It prints the contents of `/usr/share/icons/`.
```
$ ls -lh `bd icons`
or
daygeek@Ubuntu18:/usr/share/icons/Adwaita/256x256/apps$ ls -lh `bd i`
If you want to execute a file somewhere in a parent directory then use the following format. It will run the following shell file `/usr/share/icons/users-list.sh`.
If you reside in `/usr/share/icons/Adwaita/256x256/apps` and would you like to navigate to different parent directory then use the following format. The below command will navigate to `/usr/share/icons/gnome` directory.
```
$ cd `bd i`/gnome
or
daygeek@Ubuntu18:/usr/share/icons/Adwaita/256x256/apps$ cd `bd icon`/gnome
daygeek@Ubuntu18:/usr/share/icons/gnome$
```
If you reside in `/usr/share/icons/Adwaita/256x256/apps` and would you like to create a new directory under `/usr/share/icons/` then use the following format.