Change directory when logging in

I'd have though this would be easy but can't seem to find an answer anywhere.

I have an CLI install which I would like to start in a particular directory: /opt/ABC can anyone direct me to an easy way to have the machine go straight to this directory when logging in?


When you login to Ubuntu, your login shell is executed. By default, this login shell is Bash.

So using the default configuration, you have to put the command to change directory in your ~/.bashrc file.

This can be done with the following command:

echo "cd /opt/ABC" >> ~/.bashrc

This puts the line cd /opt/ABC at the end of your ~/.bashrc file, which is loaded every time you login with bash.

Another less intrusive option would be to make an alias that goes to a specific directory you use often.

For instance, I have an alias gts that goes to my deb-src directory on a mounted share.