Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

.bashrc file

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 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 Unix and Linux 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 39 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 Unix and Linux 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 Unix and Linux 10-28-2009
Smiling Dragon's Unix or Linux Image
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
 
Join Date: Nov 2007
Last Activity: 2 February 2015, 2:55 PM EST
Location: New Zealand
Posts: 1,048
Thanks: 21
Thanked 26 Times in 25 Posts

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

Or just:
Code:
<favourite editor> .bashrc

then type what you wish in there
Sponsored Links
    #5  
Old Unix and Linux 10-28-2009
drl's Unix or Linux Image
drl drl is offline Forum Advisor  
Registered Voter
 
Join Date: Apr 2007
Last Activity: 28 May 2015, 1:54 PM EDT
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 1,775
Thanks: 59
Thanked 234 Times in 210 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 Unix and Linux 10-28-2009
cfajohnson's Unix or Linux Image
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
 
Join Date: Mar 2007
Last Activity: 28 May 2015, 5:06 PM EDT
Location: Toronto, Canada
Posts: 2,883
Thanks: 0
Thanked 119 Times in 107 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 Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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:04 PM.