.bash_profile not read

murphey

Touchdown! Greaser!
Joined
Aug 21, 2008
Messages
11,655
Location
Colorado
Display Name

Display name:
murphey
Nothing I do, not source, not login, not leave and login again. This just started a few days ago.
echo $SHELL proves I'm running bash.
.bash_login nor .bashrc is being read. Which means none of my alias and shortcuts work.

any ideas?
 
Assuming you are indeed running bash, the man 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.

When an interactive shell that is not a login shell is started, bash reads and executes commands from /etc/bash.bashrc and ~/.bashrc, if these files exist. This may be inhibited by using the --norc option. The --rcfile file option will force bash to read and execute commands from file instead of /etc/bash.bashrc and ~/.bashrc.

My scorched-earth troubleshooting in this scenario is always to ensure every one of these files will echo its filename when executed, and see what order things are happening to track down where things are falling apart.
 
Nothing I do, not source, not login, not leave and login again. This just started a few days ago.
echo $SHELL proves I'm running bash.
.bash_login nor .bashrc is being read. Which means none of my alias and shortcuts work.

any ideas?
Had that problem a while back. I had to link .profile to .bashrc. This is on slackware linux. The file is executed by /etc/profile.
 
Note that BASH will look for differing files on interactive login. It executes the first one it finds:

~/.bash_profile, ~/.bash_login, and ~/.profile,

So make sure you don't have a .bash_profile if you .bash_login to run.
 
I've got echo messages at the beginning and end of all the files. Both are being displayed. Yet nothing is happening in the middle. None of the aliases but export PATH is working. Very strange.

Nothing is run. Not .bash_login, .bash_profile, .bashrc.

All this started last week. For years, it was fine. No software updates (my personal system) in the past 6 months. It's as if gremlins attacked at night.
 
Any chance the aliases are being set in an 'if' block that is being skipped due to some change elsewhere? I've seen 3-line .profile-type scripts and I've seen them go into the thousands of lines of spaghetti code. So I don't want to make assumptions about your setup. If the aliases are getting set, they could still be wiped out somewhere later along the line.
 
You want to tell us what sort of platform we are talking about?

$SHELL doesn't tell you what shell you are running right now. Use ps.

Does the entry for bash in ps begin with a dash? (i.e. -bash)

Are your startup files readable to you? Are you sure you are in your home directory (and that hasn't changed in /etc/passwd)?
 
I've got echo messages at the beginning and end of all the files. Both are being displayed. Yet nothing is happening in the middle. None of the aliases but export PATH is working. Very strange.

Nothing is run. Not .bash_login, .bash_profile, .bashrc.

All this started last week. For years, it was fine. No software updates (my personal system) in the past 6 months. It's as if gremlins attacked at night.
What happens when you do

$ . ~/.bashrc

Any error messages? Ditto for the other files.
 
What happens when you do

$ . ~/.bashrc

Any error messages? Ditto for the other files.
I get the echo message that the file is read, but nothing else happens.
You want to tell us what sort of platform we are talking about?
Mac, Darwin (System 7 Unix), 10.12.6
$ uname -a
Darwin BC-AIR.local 16.7.0 Darwin Kernel Version 16.7.0: Sun Jun 2 20:26:31 PDT 2019; root:xnu-3789.73.50~1/RELEASE_X86_64 x86_64
$SHELL doesn't tell you what shell you are running right now. Use ps.

Does the entry for bash in ps begin with a dash? (i.e. -bash)
$ ps
PID TTY TIME CMD
65440 ttys000 0:00.10 -bash
Are your startup files readable to you?
yes
Are you sure you are in your home directory (and that hasn't changed in /etc/passwd)?
yes
 
Any chance the aliases are being set in an 'if' block that is being skipped due to some change elsewhere? I've seen 3-line .profile-type scripts and I've seen them go into the thousands of lines of spaghetti code. So I don't want to make assumptions about your setup. If the aliases are getting set, they could still be wiped out somewhere later along the line.
Nope. No IFs. Stupid simple script.
 
Here's the .bash_login script. Can it get any simpler?

echo "bash login"
alias dir="ls -l | more"
alias rm="rm -i"
alias mroe=more
alias nyx="ssh -lbcohen nyx.nyx.net"
alias cs1="cd /Users/fred/Desktop/CS1Spring19"
alias cs2="cd /Users/fred/Desktop/CS2Fall18"
alias ppl="cd /Users/fred/Desktop/CSPPL"
alias cs0="cd /Users/fred/Desktop/Summer2019"

None of the aliases happen.
 
Gatekeeper issue? That think is a royal PITA and a poor solution to a problem. Another Windows style item they are incorporating.
 
Gatekeeper issue? That think is a royal PITA and a poor solution to a problem. Another Windows style item they are incorporating.
What gatekeeper?. Darwin is System 7 Unix variation. Using the command line, nothing relating to the UI. I've been a Unix/Linux developer/admin/everything for over 20 yrs. That's why this is so annoying.
 
Aliasing dir causes any respectable Unix OS to ignore any further commands.
 
The googles tell me that in bash, aliases are not expanded when the shell is not interactive, unless the expand_aliases shell option is set using shopt. When you log in, it's not interactive. Can you execute it from the command line?

Possibly an update reset expand_aliases?

Be aware that the reason is security, it's a path to running arbitrary code.
 
What gatekeeper?. Darwin is System 7 Unix variation. Using the command line, nothing relating to the UI. I've been a Unix/Linux developer/admin/everything for over 20 yrs. That's why this is so annoying.

Your post above says Mac, Darwin, so I thought you were running a recent MacOS. That has Darwin underneath. The latest 10.14 has gatekeeper.
 
Tested: Gatekeeper doesn’t care about a dir alias at all on Catalina 10.15.6. Never seen it care either.

Murph, make a brand new user and switch their shell to bash (since it’ll be zsh by default on OSX now) with...

chsh -s /bin/bash

And see if that user can alias things from .bash_profile (or whatever file you like of the usual bash config file mess).

If they can do it and you can’t... stare and compare file permission/ownership and make sure there aren’t any wacky hidden characters hiding in that file. Edited on something that added CR/LF? Etc.

I just created a new test user on the above version of Catalina (since I switched my user to zsh long ago) and it’s fine with your file cut and pasted into ~/.bash_profile from that user.

(And if nyx warms you of an attempted login that was unsuccessful, that was me by accident. LOL! I was just trying all the aliases.)

If you want to read some real silliness, check out either /etc/bashrc_Apple_Terminal or /etc/zshrc_Apple_Terminal ... to see how truly hackish the “restartable terminal” is in OSX.

Also note: If you start a shell inside a shell somehow, the second one won’t be interactive and won’t load .bash_profile for security/safety.

And -i won’t truly force it in OSX.

User bobtester here at initial launch of Apple Terminal (highly recommend iTerm2 instead because Apple Terminal sucks, but anyway...) has all his aliases.

Type “bash” he loses them.

Type “bash —verbose —init-file -/.bash_profile” and bob gets to watch the config file run and his aliases work again, three shells deep from the top. :)

(He also gets the built in OSX warning that zsh is now the default shell and the apple support document url to learn why and change his shell... GRIN...)

Forcing things with —verbose and —init-file might help see where it’s failing.

And Bob says use less instead of more. It’s waaaaay smarter. “less -Ian” in fact. And slash to search. Handles ENORMOUS files very efficiently too. Lovely stuff. Bob says so. :)

Oh yeah. Bash on OSX is like version 3. Version 5 is where the rest of the world went. :)
 
Tested: Gatekeeper doesn’t care about a dir alias at all on Catalina 10.15.6. Never seen it care either.
I'm not running Catalina but Sierra - 10.12.6. I haven't changed anything in months.
Murph, make a brand new user and switch their shell to bash (since it’ll be zsh by default on OSX now) with...

chsh -s /bin/bash

And see if that user can alias things from .bash_profile (or whatever file you like of the usual bash config file mess).
I repeat - I'm not running Catalina. Hence the default shell is NOT zsh. As noted above, I'm running bash with proof using ps
If they can do it and you can’t... stare and compare file permission/ownership and make sure there aren’t any wacky hidden characters hiding in that file. Edited on something that added CR/LF? Etc.

I just created a new test user on the above version of Catalina (since I switched my user to zsh long ago) and it’s fine with your file cut and pasted into ~/.bash_profile from that user.

(And if nyx warms you of an attempted login that was unsuccessful, that was me by accident. LOL! I was just trying all the aliases.)
I dare you to get into my system. Thru 2 firewalls (one is a hardware firewall) and only specific MAC addresses allowed thru.
If you want to read some real silliness, check out either /etc/bashrc_Apple_Terminal or /etc/zshrc_Apple_Terminal ... to see how truly hackish the “restartable terminal” is in OSX.

Also note: If you start a shell inside a shell somehow, the second one won’t be interactive and won’t load .bash_profile for security/safety.

And -i won’t truly force it in OSX.

User bobtester here at initial launch of Apple Terminal (highly recommend iTerm2 instead because Apple Terminal sucks, but anyway...) has all his aliases.

Type “bash” he loses them.

Type “bash —verbose —init-file -/.bash_profile” and bob gets to watch the config file run and his aliases work again, three shells deep from the top. :)

(He also gets the built in OSX warning that zsh is now the default shell and the apple support document url to learn why and change his shell... GRIN...)

Forcing things with —verbose and —init-file might help see where it’s failing.

And Bob says use less instead of more. It’s waaaaay smarter. “less -Ian” in fact. And slash to search. Handles ENORMOUS files very efficiently too. Lovely stuff. Bob says so. :)
I don't give a flying fig about less vs more, vi vs vim, etc.
Oh yeah. Bash on OSX is like version 3. Version 5 is where the rest of the world went. :)

*sigh*

I've been a unix admin for years...decades...in fact. I used to have my very own SUN workstation at home. Yes, I could run Ubuntu (ran RedHat before it cost $$$) or CentOS on a cheap wintel box but the Mac is more convenient for many reasons. Not the least of which is I really don't want to spend my time being a *nix admin. Not having the scripts run is aggravating and d*mned inconvenient, but not a crisis. I can set the aliases by hand, but they only exist while logged in. Need to do it all over next time I log in.

One item that's recently changed is an update to PATH because I needed Python 3.8. Both 2.7 and 3.8 are installed but one software application defaulted to Python 2.7 and I needed 3.8 for the newer libraries. That was a change inside the application and PATH. No other changes at the system level.

As for the dir command and everything else....funny, everything works perfectly the way I have it set up at work (RHEL7) exactly as at home. Bash, scripts, etc. The same. Makes my life easier.

Until, of course, when I have to work on the Win10 workstation on my desk (ssh into RHEL).
 
Last edited:
The googles tell me that in bash, aliases are not expanded when the shell is not interactive, unless the expand_aliases shell option is set using shopt. When you log in, it's not interactive. Can you execute it from the command line?

Possibly an update reset expand_aliases?

Be aware that the reason is security, it's a path to running arbitrary code.
I only work at the command line. Never needed to set expand_aliases.
 
I'm not running Catalina but Sierra - 10.12.6. I haven't changed anything in months.

Something did. :)

Browsers up to date for all the remote exploits?

Chrome has had two in the last two weeks. Full blown take the machine our exploits already in the wild. It’s that quick now. We force updated all our users yesterday.

Sierra stopped getting security updates a year ago. High Sierra stops end of this month.

It’s probably a good time for a reinstall.

Operating systems have a one month shelf life now before they’re hacked. Might as well get used to it. Haha.

Welcome to modern high kwality rental software. :)

We’d totally flatten that thing at the office. Only home gamers have time for this silliness of trying to fix perennially broken OSes. Truly.

Wouldn’t even allow it on the network. If I allowed it to touch the LAN I would have to log it as a security incident for the auditors. LOL!

Was scratching my head looking for my Darwin kernel version number to OS version number table earlier when you posted the kernel version, but once you posted this with the OS version number, I literally went from “interested in helping fix” to “wipe it, it was dead a year ago, nuke it from orbit”.

Did leave ya a voice mail saying I’d help if needed but ugh... Sierra. Copy the data off and let it die in peace. :)

We were joking offline about git. Hey at least you could check everything into github... oh... wait...

https://www.neowin.net/news/google-discloses-high-severity-security-flaw-in-github

^^^ That one is likely an unfixable design flaw, too! Bonus points for Google! LOL! ^^^
 
Something did. :)

Browsers up to date for all the remote exploits?

Chrome has had two in the last two weeks. Full blown take the machine our exploits already in the wild. It’s that quick now. We force updated all our users yesterday.
Don't use Chrome - too many security/privacy issues. I keep FireFox up to date, altho there are problems with that at work due to the VPN.
Sierra stopped getting security updates a year ago. High Sierra stops end of this month.
yes, I know. But I have hardware that can't run anything higher.
It’s probably a good time for a reinstall.
On a DSL line? Get real.
Operating systems have a one month shelf life now before they’re hacked. Might as well get used to it. Haha.

Welcome to modern high kwality rental software. :)

We’d totally flatten that thing at the office. Only home gamers have time for this silliness of trying to fix perennially broken OSes. Truly.

Wouldn’t even allow it on the network. If I allowed it to touch the LAN I would have to log it as a security incident for the auditors. LOL!

Was scratching my head looking for my Darwin kernel version number to OS version number table earlier when you posted the kernel version, but once you posted this with the OS version number, I literally went from “interested in helping fix” to “wipe it, it was dead a year ago, nuke it from orbit”.

Did leave ya a voice mail saying I’d help if needed but ugh... Sierra. Copy the data off and let it die in peace. :)

We were joking offline about git. Hey at least you could check everything into github... oh... wait...

https://www.neowin.net/news/google-discloses-high-severity-security-flaw-in-github

^^^ That one is likely an unfixable design flaw, too! Bonus points for Google! LOL! ^^^
Found the problem in the PATH statement. Had { } in the string. Everything fine now, thanks, how are you?
 
Found the problem in the PATH statement. Had { } in the string. Everything fine now, thanks, how are you?

Well... bash working, but rest of machine a security disaster waiting to happen. LOL. I wouldn’t call that “fine”. Haha.

Glad ya found the typo. :)

Luckily... I don’t have to say jack about stuff that outdated anymore.

The contracts say the auditors get to say it for me now, instead of anybody getting to pretend stuff that old and vulnerable is “fine”. Ha.

With two States now making it criminal to not report something that bad touching our network... directly or over VPN... I really don’t have to worry about it much anymore.

Multiple customer contracts in instant jeopardy if we allowed that machine to connect to anything.

If it can’t run a security-patch supported OS, it’s headed for a dumpster. (Technically a pallet. The recycling company picks up a couple times a year.)

Contracts are a wonderful thing. :)
 
Cute. I've been using that for decades. Besides, dir aint a *nix command.
This was a joke. A failed one since I have to explain it. The premise is that a Unix operating system would refuse commands from someone wanting to use dos commands.
 
Back
Top