.bashrc not executed when opening new terminal

Selah

The code in .bashrc does not execute when I open a new terminal window in Ubuntu 12.04. I noticed this when creating a .bash_aliases file. The aliases did not show up when I opened a new terminal. However when I type source .bashrc the aliases did show up.

.bashrc should be run everytime I open a new terminal window right?

How do I make this happen?

Marty Fried

It isn't necessarily run; at the top of the standard .bashrc is this comment:

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

I believe there is an option to run bash terminal as a login shell or not. With Ubuntu, gnome-terminal does not normally run as a login shell, so .bashrc should be run directly.

For login shells (like the virtual terminals), normally the file ~/.profile is run, unless you have either ~/.bash_profile or ~/.bash_login, but they are not there by default. By default, Ubuntu uses only .profile.

The standard ~/.profile has this in it:

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

This runs .bashrc if it is available - assuming $BASH_VERSION is present in your environment. You can check for this by entering the command echo $BASH_VERSION, and it should display some information on version number - it should not be blank.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

bash: /home/vishal/.bashrc: Errors when opening terminal

"~/.bashrc: Permission denied" when opening mate-terminal

.bashrc not executed when starting GitBash

Automatically Execute a command when opening a new Integrated Terminal in VSCode IDE

Make "pro" style terminal default when opening new tab/window

How can byobu be automatically started when opening a new terminal?

Binary Operator expected message when opening new terminal

Why is my ~/.profile being executed on opening a terminal?

Errors when opening terminal

Why `~/.bashrc` is not executed when run docker container?

Script in ~/.bashrc works when manually executed, but not otherwise

bash: "command not found" when calling function defined in ~/.bashrc file in `bash -c` command while opening gnome-terminal tab

Why my multiple-command vim command-mode abbreviation will be executed automatically when opening a new file?

Open gnome terminal programmatically and execute commands after bashrc was executed

Run command in new gnome-terminal and .bashrc

error when opening python in terminal

"NS=: " in terminal profile when source .bashrc

How to deactivate bash_history stats print when opening a new terminal window on my mac?

Prevent Ctrl-Alt-T from opening a new terminal window when one already exist?

Portable method of opening a new terminal window?

Opening a new tab in Firefox through the terminal

Why PPID is different when opening from terminal and when opening by doubleclicking

Opening new terminal from terminal and navigating directories (Permission denied?)

ZSH is not launched while opening a new terminal with `gnome-terminal`

When python code(.py file) executed in Pycharm terminal, new window opens and code executed and when it end it closes automatically so i can't see

PySpark works in terminal but not when executed in Python code

~/.profile, ~/.bashrc, and ~/.bash_profile not running on new terminal start up

Vim Ex mode loads when opening terminal

Setting default path when opening a terminal session