Score:0

Change directory when logging in

fo flag

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?

David avatar
cn flag
What version of Ubuntu? Please edit the question and add this info.
Score:2
vn flag

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.

benno avatar
fo flag
This worked perfectly - thanks!
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.