Ubuntu 18.04.4 (automatic upgrade from 18.04.3 just a few weeks ago)
/bin/bash
After I log in from the Gnome shell, this message appears while the screen is just plain purple and before the desktop appears:
Error found when loading /home/hfinger/.profile:
/home/hfinger/.profile: line 1: #: command not found
/home/hfinger/.bashrc: line 1: syntax error near unexpected token '('
/home/hfinger/.bashrc: line 1: '# ~/.bashrc: executed by bash(1) for non-login shells.'
As a result the session will not be configured correctly.
You should fix the problem as soon as feasible.
Trouble is, what is the problem? I have searched AskUbuntu but no-one appears to have experienced this exact problem. I don't think it is the upgrade because it had been running for about a month before this problem appeared.
I have never touched these two files because I am quite happy to let the system create and configure them. Also, I try to keep Ubuntu as vanilla as possible to avoid having to restore settings after upgrading to a new release. For what it is worth, here are the first lines of each of these files:
.profile, line 1: # ~/.profile: executed by the command interpreter for login shells.
.bashrc, line 1: # ~/.bashrc: executed by bash(1) for non-login shells.
How do I need to fix these files? What additional information should I provide so that someone more knowledgeable than I can solve this dopey problem?
This can happen if your files have a non-printing byte sequence at the start - for example a byte order mark - perhaps as a result of having edited them in a word processor program or Windows text editor.
For example, given
(where
profile
andbashrc
are local copies of my~/.profile
and~/.bashrc
with byte sequence0xFE 0xFF
inserted at the start) thenThe simplest fix is to use
dos2unix
, which removes the BOM by default:Or you can simply replace the files with fresh copies from the
/etc/skel
directory as you discovered (although obviously you will lose any customizations that way).Other ways to check for non-printing bytes are
in which a BOM will show up as a control sequence like
M-oM-;M-?#
or usingxxd
orod
to examine the byte sequences directlyThe
diff
command is helpful insofar as confirming there is a difference, but not in identifying what the difference is:The easy way to check the user's shell...
If you don't have
Users and Groups
application already installed, install it this way...sudo apt-get update
sudo apt-get install gnome-system-tools
Hit the Super key and type "Users", select
Users and Groups
application, click on the account name, then Advanced Settings, Advanced tab, and verify the correct Shell of/bin/bash
.Ubuntu 18.04.4 (automatic upgrade from 18.04.3 just a few weeks ago)
/bin/bash
I don't know what the problem was but this is the way I fixed it:
(Note:
/bin/bash
is the correct location forbash
.)Thanks everybody for your comments and assistance.