what is .bashrc - How to find the startup file - putty

Viewed 74101

I was going over this article and it states in step 3

Add the following to your .bashrc (or the appropriate startup file for your shell)  To use it immediately, be sure to type “source .bashrc” 

Any idea on how I could know what my startup file is ? I am using putty ?

5 Answers

The .bashrc is a file which is called by bash before on each start of a new interactive shell. The file can be used to setup the environment, export variables, create aliases and functions and more...

There are usually multiple instances of that file. One per system and one per user to allow system wide configuration but also customization by users ( users bashrc will be sourced after the system wide bashrc and can overwrite things). I suggest to add the lines to your user's bashrc first. The file is located in your home folder. Type:

vi $HOME/.bashrc

in order to edit the file. If you aren't familiar with the vi editor you can choose an editor of your choice like nano, mcedit or even a GUI text editor, but mind that a GUI editor's file dialog may hide the file because it's name starts with a .

Once you managed to edit the file, start a new connection or simply type

source $HOME/.bashrc

in order to parse the file

Once you use putty to SSH into your server, you can run "ls -al .bashrc" and it should show you the file, edit this with an editor you know, if none, then use vi like this "vi .bashrc".

Go to where you need to edit the file and type in "i" to put vi in Insert mode. Next type in your text. Once you are done press the escape button and ":wq", no quotes for the i or :wq.

Next you can source it by typing "source .bashrc" and the setting you added should be part of your BASH shell environment now.

check your home directory ...because it exists in user's home directory.

check /home/username/ on your terminal if you are using RHEL or CentOS.

.bashrc and .bash_profile are bash config files (bash shell script) that bash runs(execute) whenever it is started interactively. It initializes an interactive (non-login) shell session and the config is read from these files $HOME/.bashrc

.bashrc is a standard hidden file located in your home directory.It determines the behaviour of interactive shells. .bashrc runs on every interactive shell launch.If you say: $bash

For login shells, the config is read from these files:

  • /etc/profile (always sourced)
  • $HOME/.bash_profile (the rest of these files are checked in order until one is found,then no other are read)
  • $HOME/.bash_login
  • $HOME/.profile

For example: I added an echo to my .bashrc and .bash_profile files and whenever I called bash or bash -l command in terminal it showed me the echo.

Related