Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

.bashrc file

Shell Programming and Scripting


Closed    
 
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: 26 November 2016, 5:36 AM EST
Location: Belgium
Posts: 544
Thanks: 5
Thanked 42 Times in 29 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: 1 June 2016, 12:57 AM EDT
Location: New Zealand
Posts: 1,060
Thanks: 25
Thanked 29 Times in 28 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: 8 December 2016, 4:25 PM EST
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 2,019
Thanks: 149
Thanked 332 Times in 292 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: 11 July 2016, 2:55 PM EDT
Location: Toronto, Canada
Posts: 2,898
Thanks: 0
Thanked 134 Times in 118 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 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 02: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 09:37 PM
.bashrc file is an initialization file run by each interactive invocation cy163 UNIX for Dummies Questions & Answers 1 05-23-2007 11:27 AM
from bashrc to sh..?? moxxx68 Shell Programming and Scripting 3 09-13-2004 06:39 AM



All times are GMT -4. The time now is 07:54 PM.