.bashrc file | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

.bashrc file

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 10-28-2009
gentleDean gentleDean is offline
Users Awaiting Email Confirmation
 
Join Date: Oct 2009
Last Activity: 26 May 2010, 1:58 AM EDT
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
.bashrc file

Hi experts,

I am using bash shell and I cant find any .bashrc file in my home dir. Can anybody please help me out here....

If .bashrc file is not there, from where my shell config operates? Also I want to set my prompt like...


Code:
[server:working_dir]$

Please advice.
Sponsored Links
    #2  
Old 10-28-2009
ripat ripat is offline Forum Advisor  
Registered User
 
Join Date: Oct 2006
Last Activity: 17 February 2014, 7:51 AM EST
Location: Belgium
Posts: 537
Thanks: 4
Thanked 38 Times in 28 Posts
There must be a system-wide .bashrc somewhere (may be in /etc) that will server as default bashrc if not present in your home directory.

For your prompt, add this line in the .bashrc from your home directory:

Code:
PS1='[\h:\w]$ '

Sponsored Links
    #3  
Old 10-28-2009
gentleDean gentleDean is offline
Users Awaiting Email Confirmation
 
Join Date: Oct 2009
Last Activity: 26 May 2010, 1:58 AM EDT
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
To add this code in .bashrc file, I need to create it first...
can you please show me how can I create it? format?
    #4  
Old 10-28-2009
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
 
Join Date: Nov 2007
Last Activity: 15 April 2014, 11:25 PM EDT
Location: New Zealand
Posts: 1,026
Thanks: 19
Thanked 22 Times in 21 Posts

Code:
echo 'PS1=\'[\h:\w]$ \'' > .bashrc

Or just:
Code:
<favourite editor> .bashrc

then type what you wish in there
Sponsored Links
    #5  
Old 10-28-2009
drl's Avatar
drl drl is offline Forum Advisor  
Registered Voter
 
Join Date: Apr 2007
Last Activity: 17 April 2014, 3:22 PM EDT
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 1,631
Thanks: 24
Thanked 177 Times in 161 Posts
Hi.

On Linux systems there are files often used as sources for new account (login) creations. On the system:

Code:
OS, ker|rel, machine: Linux, 2.6.26-2-amd64, x86_64
Distribution        : Debian GNU/Linux 5.0

the .bashrc file is at:

Code:
/etc/skel/.bashrc

It's about 100 lines and should be a good start.

Best wishes ... cheers, drl
Sponsored Links
    #6  
Old 10-28-2009
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
 
Join Date: Mar 2007
Last Activity: 12 April 2014, 10:59 AM EDT
Location: Toronto, Canada
Posts: 2,875
Thanks: 0
Thanked 108 Times in 101 Posts
Quote:
Originally Posted by gentleDean View Post
I am using bash shell and I cant find any .bashrc file in my home dir. Can anybody please help me out here....

man bash:

Code:
       When bash is invoked as an interactive login shell, or as a
       non-interactive shell with the --login option, it first reads
       and executes commands from the file /etc/profile, if that file
       exists. After reading that file, it looks for ~/.bash_profile,
       ~/.bash_login, and ~/.profile, in that order, and reads and
       executes commands from the first one that exists and is
       readable. The --noprofile option may be used when the shell is
       started to inhibit this behavior.

       When an interactive shell that is not a login shell is started,
       bash reads and executes commands from ~/.bashrc, if that file
       exists. This may be inhibited by using the --norc option. The
       --rcfile file option will force bash to read and execute
       commands from file instead of ~/.bashrc.



---------- Post updated at 04:29 PM ---------- Previous update was at 04:23 PM ----------

Quote:
Originally Posted by drl View Post
On Linux systems there are files often used as sources for new account (login) creations. On the system:

Code:
OS, ker|rel, machine: Linux, 2.6.26-2-amd64, x86_64
Distribution        : Debian GNU/Linux 5.0

the .bashrc file is at:

Code:
/etc/skel/.bashrc

It's about 100 lines and should be a good start.

100 lines is excessive. On mine (Mandriva), there are three uncommented, non-empty lines.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how do i look for my .bashrc file npatwardhan Shell Programming and Scripting 12 01-28-2009 01:43 PM
Can I modify the .bashrc file instead of .profile file to customize my login? Hyunkel Shell Programming and Scripting 1 09-25-2007 08:37 PM
.bashrc file is an initialization file run by each interactive invocation cy163 UNIX for Dummies Questions & Answers 1 05-23-2007 10:27 AM
from bashrc to sh..?? moxxx68 Shell Programming and Scripting 3 09-13-2004 05:39 AM



All times are GMT -4. The time now is 08:19 PM.