There are several ways to change from one directory to anotherYou already know that the most used is the cd command from the terminal, but it is not the only one. We can also create environment variables like $ HOME to point directly to routes that we use often and thus avoid having to type them completely to go to them. In this tutorial we will see how we can do that in a simple way by editing one of the configuration files of Bash, our favorite command interpreter for Linux.
For example, imagine that you want to always have any directory accessible. Since you work a lot with directories and you would like to change from one to another saving keystrokes, that is, quickly without having to always type cd in front of the path of the directory you want to go to in the console. Well, let's see step by step how to do it by editing the .bashrc file that is in our personal directory (since it will only affect our user).
For editing we must use your favorite text editor, like for example nano:
And there we will add a line at the end which is:
shopt -s autocd
Save the modification and exit the text editor. Now we must to update changes with:
Now everything is ready, every time you want to go to a directory, you just have to type its name, without accompanying it with a cd in front of it. For example, if we want to access Desktop and I am in my user's home directory, I could do this:
But it is no longer necessary, with a simple:
It would be enough to go. And if later we want go to another directory inside it called Test:
And it would already be in ~ / Desktop / Test saving us the two cd's that we should have inserted if we had not done the setting...