0

Everytime I run my ubuntu VM I have to run source ~/.bash_profile I was wondering if there's any way which would run this command automatically as soon as I boot my VM up without me having to do this every single time.

kleash
  • 103
asd
  • 1

2 Answers2

0

What is a login or non-login shell?

When you login (type username and password) via console, either sitting at the machine, or remotely via ssh: .bash_profile is executed to configure your shell before the initial command prompt.

But, if you’ve already logged into your machine and open a new terminal window (xterm) inside Gnome or KDE, then .bashrc is executed before the window command prompt. .bashrc is also run when you start a new bash instance by typing /bin/bash in a terminal.

Why two different files?

Say, you’d like to print some lengthy diagnostic information about your machine each time you login (load average, memory usage, current users, etc). You only want to see it on login, so you only want to place this in your .bash_profile. If you put it in your .bashrc, you’d see it every time you open a new terminal window.

That was an excerpt from a blog post that might help you. .bash_profile vs .bashrc

d4n3sh
  • 66
0

save a cmd.sh with command you want to run.

sudo chmod +x cmd.sh

sudo crontab -e

enter the below line at end of file

@reboot path_to_your_file/cmd.sh

save and exit.

warning @reboot is a non standard syntex old crontab will fail.

Aravind
  • 908