0

am on a Kali box and ~/.bash_profile doesn't seems to work in Kali. Is it called by some other filename in Kali?

  • The title says "doesn't seem to have" (it's not there), the question "doesn't seem to work" (it's there, but has no effect) – which is it? – DonHolgo Nov 20 '19 at 10:48
  • I think it was not there by default, a script tried creating it and now its there. But doesn't seems to work. – Sam Nov 20 '19 at 10:49
  • I think ~/.bash_profile is not the file name in kali distro – Sam Nov 20 '19 at 10:49
0

The file ~/.bash_profile will be used by the bash shell if it is invoked as a login shell.

If the file does not exist (it does not need to exist), then it may be created by a user.

If the shell is not bash, or if the bash shell is not a login shell (such as it won't be if it's used for running a script or starting an interactive non-login shell session), then the file will not be used.

Other shells may read ~/.profile for login shells, and bash does this too if ~/.bash_profile does not exist.

To figure out what shell you are using for your login shell, use

getent passwd username

where username is your username. The login shell will be the last :-delimited item in the resulting line.

Example:

$ getent passwd myself
myself:*:1000:1000:Kusalananda,,,:/home/myself:/usr/local/bin/zsh

This means my login shell is zsh.

Note that your choice of Linux distribution has very little (nothing) to do with whether ~/.bash_profile is used or not. It is your choice of login shell that determines this.

  • its showing bash for me – Sam Nov 20 '19 at 11:11
  • I know about this though. There is another qucick way to check echo $0 – Sam Nov 20 '19 at 11:12
  • @Sam Could you clarify the question with what you are trying to do and what actually happens, please? Note that echo $0 would show you what the current shell was, most of the time, not necessarily what your login shell is. – Kusalananda Nov 20 '19 at 11:12
  • @Sam Also note that this ~/.bash_profile file is only ever read when the shell starts. Changes to the file would not gain effect until the next login shell starts. – Kusalananda Nov 20 '19 at 11:15
  • okay, I want to update ~/.bash_profile file I know its there in ubuntu but not sure about kali. I ran someone's script in my kali box which was meant to be ran on a ubuntu machine. That script either created ~/.bash_profile or overwrited it. Am not sure which of the two it did because I dont know if that file existed before running that script or not. – Sam Nov 20 '19 at 11:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.