1

When i turn on my raspberry pi in command line mode it opens up with bashrc each time i startup my pi.If i open my terminal the same bashrc script opens first.Can anyone give me a solution. Thanks in advance

3

I'm guessing you've been misled by tutorials or blogs which imply or explicitly state that .bashrc can be used for things you want to happen at boot.1 This is essentially false, although it has side effects that might make it seem that otherwise.

.bashrc is a shell initialization file. There are a few different flavours of these, which you can read about in man bash under INVOCATION. For example:

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

You can think of an interactive shell as the command line. "An interactive shell that is not a login shell" applies to almost any shell that opens in a terminal, amongst other things. The "that is not a login shell" is often negated by the fact that ~/.profile and/or ~/.bash_profile, which are initialization files called when starting an interactive shell that is a login shell, source ~/.bashrc. When this is the case, .bashrc is run when starting any interactive shell.

Booting the system and starting an interactive shell are very different events, so if you put something in .bashrc and expect it to run at boot, or to only run at boot, expect to be surprised.


  1. Authors of which should be banned from posting anything about how to use computers on the internet.
1

Undo the modification you have done.

Bashrc is a simple file name and has no special meaning but the bash shell (that what makes the command line) uses a configuration file $HOME/.bashrc. Notice the dot at the beginning of the filename. It makes the configuration file invisible. You can show it with ls -a. Check if you have the .bashrc file.

  • I have been using UNIX/linux (as a casual user) for ages, but I still don't understand why and how to use the weird dot thing. I still remember once upon a Rpi2 time it took me 3 hours to search for a invisible dotted file (and no luck and gave up!) . To me Windows and Linux are relatively like heaven and hell. Actually I gave up Rpi after Rpi1 altogether, only came back at Rpi3 when GUI has become barely bearable. I hope Rpi5, Win10, with SuperShell, only for super users and never newbies. I always think UNIX/C are for geeks with IQ above 120 (poor me only 97!) – tlfong01 Sep 8 at 5:30

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.