I am new to Ubuntu.
Whenever I open a terminal my current working directory
/home/Varun (as found by typing
Is there any way I can make the terminal's path to be set as
/home/Varun/Desktop/Java Files when it opens?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
Just run the following command in your terminal:
echo "cd ~/Desktop/Java\ Files" >> ~/.bashrc
The above command will add a new line in your
~/.bashrc file that contain
cd ~/Desktop/Java\ Files and that will change your default working directory to
/home/Varun/Desktop/Java Files when you will open the terminal.
Reopen the terminal and you will see the difference.
Although changing the
$HOME variable and calling
cd command (i'll use cmd for short) in
.bashrc file is right answer to your question,
i find it more comfortable to create alias (for example
cdh) which takes me directly to directory i want.
The reason is that all files which configures other programs (Just like
.bashrc for example) stay in default
$HOME directory and i can work in my "
cdh directory" without interuption from theese files.
If i needed to go back to
$HOME directory i can allways use
In some linux distros the
.bashrcfile is shipped with command or commands which runs or run one or multiple other files intended for that specific use (for example
so decide for yourself if you want to use them or not,
in case you want to use them, just use it the same as you use
.bashrcbut with commands inteded for the specified file.
.bashrc (or in
.bash_aliases or whichever file you've chosen)
alias cdh='cd /home/Varun/Desktop/Java Files'
if you don't like
cdhalias don't be afraid to use different name but make sure there isn't any other cmd or alias named like this, couse you could make that cmd more or less unusable.
You can check if the name is taken by triyng to call it but i would sugest a
typecmd with argument of name of another cmd.
typecmd should tell you if the given cmd is alias, binary file, or bash script, or ......... whatever. And therefore will tell you when cmd doesn't exist. (Which is what you want in this case)
Just to add
If someone is using zsh shell than
nano ~/.zshrc ( open the configuration file)
and at bootom add
cd ~/Desktop/Java\ Files
so the tweak is what ever shell you are using
(echo $0 ) just add the command you usually use and it will be executed.