Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Suddenly, I start from the root directory not my home directory when I login. I want to start from my home directory

From some point, suddenly (I guess after an Ubuntu update?), it starts in the root directory when I open a new terminal.
I want to start from my home directory as before.

The below is my shell script(I removed all the comments).
I am running Ubuntu on WSL2 on Windows 10

export ZSH="/home/myubuntu/.oh-my-zsh"
ZSH_THEME="bira"
DISABLE_LS_COLORS="true"
plugins=(git)

source $ZSH/oh-my-zsh.sh

alias tre='tree -a -C -I '\''node_modules|.git'\'' --dirsfirst'

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

#cd workspace
if [ "$PWD" = "$HOME" ]; then cd workspace; fi

# added by travis gem
[ ! -s /home/myubuntu/.travis/travis.sh ] || source /home/myubuntu/.travis/travis.sh

This is Ubuntu info

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

╰─$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.3 LTS
Release:        20.04
Codename:       focal

Anyone knows how to fix this?

>Solution :

I see in the comments that you got this working, but there are several ways to do this under Windows Terminal:

  • Under Windows 10 21H2 and Windows 11, you can specify a Linux directory instead of the Windows path for startingDirectory. So now /home/taeil will work (assuming you are upgraded). See this answer on Stack Overflow for details and a link to the Microsoft Doc.

  • Under previous versions, you do need to use the Windows format \\wsl$\ path (quoted) as noted in the comments. In your case, it looks like this would be \\\\wsl$\\Ubuntu\\home\\taeil

  • Personally, for using your Linux home directory as a starting point, I recommend this technique (my answer in that same Stack Overflow question). Just start wsl with wsl ~ to start in your home directory.

  • Also, with Windows 10 21H2 and Windows 11, wsl --cd ~ works.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading