CLI - Not working properly in Ubuntu terminal

Hello everyone. My problem is when I close the terminal and re-open it then type the ‘exercism’ command it won’t work but it will work after I source the bash_profile.

So what I want to fix is when I open the terminal, I can type the ‘exercism’ command without typing the “source ~/.bash_profile”. Can someone help me with this?

I used exercism-3.1.0-linux-x86_64.tar.gz for installation.

Image for reference

Are you using bash as your shell? Does echo $SHELL show /bin/bash (or similar)?

The man bash page says,

When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.

What does echo $- show? Is there an i (interactive) in there?

It show /bin/bash and there is an i

That’s pretty … odd. You may want to try logging out and logging back on and seeing that fixes the issue. If not, you may want to check your local man bash and see if it invokes different rc files.

Thank you! Will do that and I’m using virtualbox, does it affect the cli?

I’m still a newbie on using vm, linux, bash, etc.

VirtualBox on Windows? There you could work with WSL which gives a great Linux experience there.


I tried WSL 2, it wasn’t a great experience for me. It slows down my pc because it’s an old one :face_holding_back_tears: that’s why I use virtualbox.

The fact that the OS is running on a VM shouldn’t affect how it operates (in this regard).

Wow, that’s weird. Should be even better integrated than VirtualBox.

But yeah, has nothing to do with your problem at all.

The fact that you have to source your bash_profile means your terminal is not starting a login shell. You could check your terminal’s settings to launch a login shell, or you could move the exercism-specific stuff from ~/.bash_profile to ~/.bashrc

See 6.2 Bash Startup Files in the manual


It’s working!

I did what @glennj suggested, I moved the the $PATH to ~/.bashrc since the terminal is starting as a non-login shell, it first reads and execute commands from the ~/.bashrc instead of ~/.bash_profile. Thank you @glennj :smiley: