Linux Bashrc File and Usage Examples

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/linux-bashrc-file-and-usage-examples/
PINTEREST
PINTEREST
INSTAGRAM
  1. Introduction To Linux Bash Programming
  2. Linux Bash Directories and Files
  3. Linux Bash Environment Variables
  4. Linux Bash Variables
  5. Linux Bash Functions
  6. Linux Bash If Else Conditionals
  7. Linux Bash Create and Run Script Files
  8. Linux Bash Operators
  9. Linux Bash Arrays
  10. Linux Bash Input, Output and Redirection
  11. Linux Bash History
  12. Linux Bash Alias
  13. Linux Bash .bashrc File
  14. Linux Bash Debugging

Linux and related distributions like Ubuntu, Debian, CentOS, Fedora, RedHat, … provides shell to manage systems. By default bash shell is used by the most of the distributions. Every shell in Linux have some configuration, environment variables, etc. We generally need to change them after opening a new shell. .bashrc is used to set shell related configuration during new shell creation. In every new shell .bashrc file is fired before we get the new shell. In this tutorial we will look how to use .bashrc .

Edit .bashrc

.bashrc provides very flexible way to edit new shell configuration. Each user will have the .bashrc file in their home directory. .bashrc is a hidden file and not listed with ls or File managers. But we can edit it just providing the path like below.

Following command will open .bashrc of current user with nano text editor

Which will look like below.

Edit .bashrc

Edit .bashrc

Add New Path Variable

One of the most popular use case for add new Path for the current user is adding to the .bashrc . In this example we will add path /opt/bin/ as new path for the current user.

LEARN MORE  How To Linux Bash For Loop In Files?

Add Alias

Another useful usage for .bashrc is defining new alias for the current user. In this example we add alias for mv  command.

Change Prompt

Linux provides prompt for each interactive shell. This generally provides the user name , host name and path. We may want to use more simple prompt just like $ we can set from .bashrc with the following command.

Source Other Configuration File

We may need to load other configuration and shell startup file other than .bashrc. In this situations we can use .bashrc too.

Bashrc vs Bash_profile

There is an alternative to bashrc file which is named bash_profile . bash_profile provides global configuration for all users. Bashrc is limited with current user.

Reload Bashrc

Sometimes we need to reload bashrc file without logout and login. We can use source mechanism to reload bashrc. One of the following commands can be used to reload bashrc.

or

  1. Introduction To Linux Bash Programming
  2. Linux Bash Directories and Files
  3. Linux Bash Environment Variables
  4. Linux Bash Variables
  5. Linux Bash Functions
  6. Linux Bash If Else Conditionals
  7. Linux Bash Create and Run Script Files
  8. Linux Bash Operators
  9. Linux Bash Arrays
  10. Linux Bash Input, Output and Redirection
  11. Linux Bash History
  12. Linux Bash Alias
  13. Linux Bash .bashrc File
  14. Linux Bash Debugging
RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/linux-bashrc-file-and-usage-examples/
PINTEREST
PINTEREST
INSTAGRAM

You may also like...

1 Response

  1. 11/07/2017

    […] Linux Bashrc File and Usage Examples […]

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)