0

Any welcome text, modifying PS1, aliases not working after restart.

I have to put "source ~/.profile" every new terminal i open.

Wishing for complete fix for these all to effect everytime on launching terminal.

USING Ubuntu 14.04

2
  • 2
    ~/.profile is not sourced in non-login shells, that's why it doesn't work. You should customize the prompt in ~/.bashrc as explained in the accepted answer to the duplicate question.
    – kos
    Jan 2, 2016 at 15:47
  • Lazy people can add source $HOME/.profile into .bashrc to make that work, but that's silly and not how should be done properly Jan 2, 2016 at 19:12

1 Answer 1

0

Setting PS1 and defining aliases (and functions) should be done in .bashrc since this file is read at the start of every interactive non-login shell.

.profile is only read at the start of a login shell and should really only be used to set to set environment variables and other settings that should be inherited by child processes launched by the shell.

For more information, see Section 6.2 of the Bash manual, Bash Startup Files.

To ensure that the Bash-specific settings are also set for login shells, the default .profile for Ubuntu contains the following lines:

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"
    fi
fi

See also: this excellent answer to the Difference between Login Shell and Non-Login Shell?

Not the answer you're looking for? Browse other questions tagged .