I have a guest user account on my Debian system with XFCE desktop.

It has a ~/.profile file added by default. The last few lines of this file are:

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then

echo .profile executed

The last echo command is added by me. I have ensured that $HOME/bin exists.

guest@debian:~$ ls -ld $HOME/bin
drwxr-xr-x 2 guest guest 4096 Jan  9 09:42 /home/guest/bin

After booting my Debian system, I log into my XFCE desktop using the guest account and launch Terminal (xfce4-terminal). But I do not see any evidence that ~/.profile was executed.

guest@debian:~$ echo $PATH

man bash makes it pretty clear that ~/.profile is read and executed in an interactive login shell or a non-interactive shell with the --login option. ~/.bashrc is executed in interactive non-login shell, so it seems alright that when xfce4-terminal launches bash, ~/.profile is not executed.

If ~/.profile is not executed when we launch a new Terminal, why is the PATH updated in ~/.profile?

Shouldn't Debian provide the PATH update in ~/.bashrc so that it is available to the user when the user launches a terminal?

  • This article explains nicely which startup script is run when. Jan 9, 2018 at 5:08
  • What do you mean by "the PATH updated in ~/.profile"?
    – Emily E.
    Jan 9, 2018 at 9:19
  • @EmilyE. See the first code block in my question. It updates the existing (inherited) PATH by adding $HOME/bin to the beginning of the PATH. Jan 9, 2018 at 12:31
  • Basically .profile is (intended to be) sourced once per login session. If you login from a terminal you'll see your echo. In a X session it's simulated - something else will source that file to emulated legacy behavior (once for your session). When you launch a terminal from within XFCE your not logging in again, your just forking some process. Also for better "evidence" why don't you do ~ "echo .profile executed `date` >> /tmp/profile-hits".
    – spinkus
    Jan 13, 2018 at 4:18
  • 1
    Questions about general computing hardware and software are off-topic for Stack Overflow unless they directly involve tools used primarily for programming. You may be able to get help on Super User.
    – ΔRob
    Jan 16, 2018 at 16:03

4 Answers 4


From man bash:

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....

When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists....

I understand that

  1. ~/.bashrc: for interactive shell
  2. ~/.bash_profile, ~/.bash_login, ~/.profile: for login shell

So, if you need to modify PATH in Terminal, which is an interactive shell, then you might want to put that PATH settings in ~/.bashrc; or, alternatively, you can source ~/.profile from ~/.bashrc whenever you are in non-login shell, example:

shopt -q login_shell || . ~/.profile

As for why PATH is set in ~/.profile as a recommended way, I believe that user's defined PATH should be set right when he/she logins, and "login" can be bash, zsh, or GUI, or somewhat else.

Senario 1: Some user might want non-X as the default working environment; and X is called by running startx normally or automatically from ~/.profile when the login virtual terminal is tty7.

[ -z $DISPLAY -a $XDG_VTNR -eq 7 ] && exec startx

In this case, users chose carefully what to set in ~/.profile, ~/.bashrc, and ~/.xinitrc, so that they have the desired set of enviroment variables ---PATH, EDITOR, VISUAL, BROWSER, etc.--- whether he/she is working in:

  1. Consoles (Ctrl+Alt+F[1-6]), or logging in without X via ssh: ~/.profile + ~/.bashrc
  2. Non terminal progams in X: ~/.profile + ~/.xinitrc
  3. Terminal emulators in X: ~/.profile + ~/.xinitrc + ~/.bashrc

So, setting PATH in ~/.profile is the best choice. Users can set EDITOR as vim in ~/.profile (in non-X), but change it to emacs in ~/.xinitrc (in X).

Senario 2: A GUI user who logins to XFCE instead login as bash; so PATH could be set in ~/.xsessionrc as explained here.

Senario 3: A zsh user can set PATH in ~/.zprofile. Interactive settings for bash are places in ~/.bashrc, and interactive settings for zsh are placed in ~/.zshrc.


~/.profile is executed when you log in using the console mode and not the gui mode. You can use keys F1, F2 ... to log in using console mode.

  • 3
    Your answer is incorrect. ~/.profile is executed in an interactive login shell well as a non-interactive shell with the --login option. It has nothing to do with whether the shell is launched in tty or GUI. Even in GUI, you can launch an interactive login shell with the su - command and ~/.profile would be executed. See man bash for more details. Having said that, what is your answer to the actual question asked: Why is PATH defined in ~/.profile if it is not going to be available in an interactive non-login shell? Jan 9, 2018 at 5:53
  • Thanks for correcting me. I just went through this. It raises a similar question. I personally don't have an answer to this.
    – Vineet Bhat
    Jan 9, 2018 at 6:16

Edit -> Profile Preferences -> Title and Command -> "Run command as a login shell"

The usual ~/.profile loads ~/.bashrc if it is available, if - assuming $BASH_VERSION is present in your environment.

Keep in mind though that ~/.profile is ignored if if there's ~/.bash_profile or ~/.bash_login in your home and that, as a result of it being ignored, ~/.bashrc isn't sourced, too.

This answer was sourced from here while researching a similar issue. And this answer from Unix & Linux mentions how Debian handles shell configs with links that may help.

  • In recent-ish Debian default files, .profile checks if it's running Bash, and if so, loads .bashrc. In the glacial terms of Debian development, this is a relatively recent arrangement, and certainly not generalizable to other distributions.
    – tripleee
    Jan 18, 2018 at 6:07
  • @Yokai So why does Debian define a custom PATH in ~/.profile even though it is not going to be executed at all by default when we launch Bash in XFCE Terminal? Jan 23, 2018 at 9:00

My understanding has always been that .bashrc is specific for bash and .profile is cross-shell. This may not be an issue for most of the home users, but I am sometimes on a system where users prefer ksh (and enforce that choice on new users). If for some reason you get a bournshell, .profile is also used. Note that zsh and csh do not use .profile.

  • Sorry, I am confused. Which part of my question are you answering? Jan 23, 2018 at 8:58
  • If ~/.profile is not executed when we launch a new Terminal, why is the PATH updated in ~/.profile? Jan 26, 2018 at 17:22

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.