/etc/profile does not get sourced when logging into a terminal window

Bug #1406980 reported by hufemj
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gnome-terminal (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

I wanted to change the command prompt and so made the following change within /etc/bash.bashrc:

#PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
PS1='${debian_chroot:+($debian_chroot)}\h:\w\$ '

When a terminal window is opened, the prompt is unchanged from the original. If I reboot, login and again open a terminal window the prompt is still unchanged. However, manually executing the following from the terminal window changes the prompt as desired:

source /etc/profile

It seems that /etc/profile is not automatically run when the terminal window is first opened.

From the documentation I've seen (https://help.ubuntu.com/community/EnvironmentVariables, http://bencane.com/2013/09/16/understanding-a-little-more-about-etcprofile-and-etcbashrc/ and other posts), /etc/bash.bashrc should be executed from /etc/profile during a terminal login.

ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: ubuntu-release-upgrader-core 1:0.220.6
ProcVersionSignature: Ubuntu 3.13.0-43.72-generic 3.13.11.11
Uname: Linux 3.13.0-43-generic x86_64
ApportVersion: 2.14.1-0ubuntu3.6
Architecture: amd64
CrashDB: ubuntu
CurrentDesktop: Unity
Date: Thu Jan 1 14:36:48 2015
InstallationDate: Installed on 2014-09-12 (111 days ago)
InstallationMedia: Ubuntu 14.04.1 LTS "Trusty Tahr" - Release amd64 (20140722.2)
PackageArchitecture: all
SourcePackage: ubuntu-release-upgrader
Symptom: dist-upgrade
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
hufemj (hufemj-yahoo) wrote :
affects: ubuntu-release-upgrader (Ubuntu) → gnome-terminal (Ubuntu)
Revision history for this message
Marius Gedminas (mgedmin) wrote :

Ubuntu's default ~/.bashrc (copied over from /etc/skel/.bashrc when you create new user accounts) overrides PS1 when $TERM is xterm*. When you open new terminal windows or tabs, bash sources /etc/bash.bashrc and then ~/.bashrc, and thus your global PS1 setting is overwritten.

Do the change in ~/.bashrc instead of in /etc and you'll be fine.

Changed in gnome-terminal (Ubuntu):
status: New → Invalid
Revision history for this message
Marius Gedminas (mgedmin) wrote :

(Although TBH you're right when you say /etc/profile isn't sourced on Ubuntu -- that's because the default gnome-terminal profile doesn't run the shell as a login shell. There's a checkbox in the profile preferences dialog you can toggle to enable that.)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.