Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When You press [ALT+F1...F6] on Linux machine You see "virtual terminal" usually. When I log in via virtual terminal on my Debian machine - bash does not implement settings from $HOME/.bashrc and $HOME/.profile files! What file must I use to place bash settings for virtual terminal?

I tried to debug this:

    $ strace  -e open  bash --login 2>&1 | grep -P "\.bash|profile"

    open("/etc/profile", O_RDONLY|O_LARGEFILE) = 3
    open("/etc/profile.d/", O_RDONLY|O_LARGEFILE) = 3
    open("/home/ruslan/.bash_profile", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
    open("/home/ruslan/.bash_login", O_RDONLY|O_LARGEFILE) = 3
    open("/home/ruslan/.bash_logout", O_RDONLY|O_LARGEFILE) = 3
    open("/etc/bash.bash_logout", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)

~/.profile - not present!

share|improve this question

migrated from Sep 9 '12 at 9:15

This question came from our site for professional and enthusiast programmers.

Very strange. Is your shell set to bash? – Ignacio Vazquez-Abrams Sep 9 '12 at 9:28
I think yes. echo $SHELL - /bin/bash – Ruslan K Sep 9 '12 at 17:15
up vote 2 down vote accepted

When you computer boots it starts init and checks a file (e.g. /etc/inittab) for processes to start. Usually this file contains a few lines like the one below.

c5:5:respawn:/sbin/agetty 57600 tty2 xterm-256color

Loose translation:
When in run level 5 (multiuser mode), start agetty (log-in process), on console 2 (ALT-F2). If the process dies (e.g. after you log out) start a new one (respawn).

If you log in that that agetty then you will start a log-in shell. This can be bash. It can be another shell. (You can set the default shell with chsh).

If you have bash configured as default shell then it will start bash and look in these places: (note, this files are check when bash is invoked specifically as a log-in shell)

  • /etc/profile
  • ~/.bash_profile
  • ~/.bash_login
  • ~/.profile

As you can see this includes the $HOME/.profile you mentioned earlier, but not $HOME/.bashrc

In this case of an interactive but non-login shell, bash checks /etc/bashrc and ~/.bashrc.

I suspect that last part answers your question. (Test it with bash -l or bash --login).

share|improve this answer

You must log in to answer this question.

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