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 Sign up for Apple One on iPhone and iPad
- › How to View 3D Halloween Characters in AR Using Your Phone
- › How to Set Up and Use Home & Away Routines with Google Assistant
- › How to Track Changes in a Microsoft PowerPoint Presentation
- › How to Bookmark Multiple Tabs in Safari on iPhone and iPad