By default, new Terminal windows open to your Home directory. However, if there’s another directory you use often that you want immediate access to when you open the Terminal, there’s an easy way to set this up.
.bashrc file in your Home directory contains commands that run when you open a Terminal window. So, we can add a
cd command to change to a specific directory as soon as the Terminal window opens. To do this, press Ctrl+Alt+T to open a Terminal window. As we mentioned, you are in your Home directory by default, which is where you want to be right now.
We’re going to edit the .bashrc file, so type the following command to open it. You can use whichever text editor you want to use, but we’re going to use gedit in our example.
Scroll to the bottom of the .bashrc file and add the following command.
The tilde character (~) is a shortcut for your Home directory, which in our example, is
/home/lori. So, the full path for the directory in the above command is
~/HTGArticles with the directory you want to open when you open a Terminal window.
The following line is a comment we added above the
cd command, explaining what the command is doing. You don’t have to add a comment, but it helps make the .bashrc file easier to understand. The pound sign (#) at the beginning of a line indicates that line is a comment.
# Open to HTGArticles directory
Once you’ve added the command to the file, click “Save” in the upper-right corner of the window to save the file.
Close the .bashrc file by clicking the “X” button in the upper-left corner of the window.
You must restart the Terminal window for this change to take effect. To close the Terminal window, either type exit at the prompt and press Enter, or click the “X” button in the upper-left corner of the window.
Now, press Ctrl+Alt+T to open the Terminal again. You are immediately in the directory you specified in the .bashrc file. You can still navigate to any other directory, but this is helpful if you work in this directory the most.
If you use both Nautilus and the Terminal to work with files, you can open a specific directory in Nautilus from the Terminal as well as open a Terminal window to a specific directory from Nautilus.
- › How to Define the Base Directory for the “cd” Command in Linux
- › Why Unlimited Mobile Data Isn’t Actually Unlimited
- › What Can You Do With the USB Port on Your Router?
- › Here’s How Mozilla Thunderbird Is Making a Comeback in 2022
- › Why Do I See “FBI Surveillance Van” in My Wi-Fi List?
- › 4 Ways to Ruin Your Smartphone’s Battery
- › ExpressVPN Review: An Easy-to-Use and Secure VPN for Most People