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
- › Microsoft Edge Is Getting AI Chat and a New Look on Windows
- › Wyze Is Down, It’s Not Just You
- › The OnePlus 11 Is Here, but With a Rough Start
- › The Best Earbuds for iPhone Fans Just Hit Their Lowest Price
- › How to Block or Unblock Someone on TikTok
- › Microsoft Is Transforming Bing Into an AI Search Engine