Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
google site



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-09-2010
Registered User
 

Join Date: Feb 2009
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Where are my bash_profile and bash_login/logout files?

I'm on my iMac, reading about bash from a book (learning the bash shell). It talks about these three files, but I can't find them. Am I to assume that these files don't have to be in and I can create them myself if I want to?
Sponsored Links
  #2  
Old 03-10-2010
kiruthika_sri's Avatar
Registered User
 

Join Date: Feb 2010
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
These files are hidden files.And these files will be there under your home directory. If you want to check this put ls -a in your home directory else try with the find command like,
Code:
   find ~ -type f -iname ".bash*"

  #3  
Old 03-10-2010
Registered User
 

Join Date: Feb 2009
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
I did that (in Darwin it's find ~ -iname ".bash*" and all I got was .bash_history

any idea where the logout files would be -- assuming they're optional and I can create them myself?

the .profile file is the substitute for .bash_profile according to the book -- and that file is in there.
  #4  
Old 03-11-2010
Registered User
 

Join Date: Mar 2010
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
I am pretty sure that they dont exist on a mac and you have to create them. afterwards so that your changes take effect, do


Code:
 source .bash_profile

  #5  
Old 03-11-2010
Registered User
 

Join Date: Mar 2008
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by jhullbuzz View Post
I am pretty sure that they dont exist on a mac and you have to create them. afterwards so that your changes take effect, do


Code:
 source .bash_profile

Correct you have to create the files in OS X. As for log in/out hooks you don't set them in your ~/.bash_profile you set them in your ~/Library/Launchagents and use the loginhook.plist file to run log in and look out hooks, or use launchd to run them at log in and log out.
  #6  
Old 03-22-2010
Registered User
 

Join Date: Feb 2009
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Let me update this thread since I'm currently reading about Environment variables.

I'm on OS X Snow Leopard, and I'm trying to find out where they are. The book I have (for bash general) says that they are in the .bash_profile file, but since I don't have that, where would they be? I looked in Libary/Launchagents but I didn't get the loginhookfile.plist you mentioned.

anywhere else I might look? I'm just curious -- I want to learn all about this stuff
  #7  
Old 03-22-2010
Registered User
 

Join Date: Mar 2008
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Well, I recommend you read up on launchd, as it can run scripts at start up globally, when all users log in, or when a specific user logs in. Launchd is one launch daemon to rule them all so to speak.

For the loginhook, I actually misspoke (err mistyped?) earlier. I jumped a step ahead of myself. You need to modify the loginwindow.plist to enable a loginhook.

/Library/Preferences/com.apple.loginwindow.plist

Once you write your script you want to run, and place it in a system locally, you can modify that property list to run a loginhook script.


Code:
sudo defaults write com.apple.loginwindow LoginHook /path/to/script

There is a depreciated piece of software from Carbon Copy Cloner - Home called loginhelper or something like that. It is no longer supported, but is a GUI front end for creating log in hooks and from what I have read, people still use it currently.

Now, I don't have my bash book on me, but from what I understand about bash is that there is an order of config files it reads and looks for. Files like ~/.bash_profile and ~/.bash_rc and so forth. If those files are not present, it will just read the default profile that comes from the standard installation. By default, the user template does not create a .bash_profile, but if you create one, you can still have the Unix part of OS X take advantage of it. One example is that I added a function to my ~/.bash_profile to export man pages to PDF.

Add PDF export of Man pages in OS X | tlarkin.com

So, you can still edit that. However, if you want certain things to happen at start up or login you are best off using a login hook script or launchd to accomplish it.
Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
bash_profile does not working smallman UNIX for Dummies Questions & Answers 1 01-20-2009 10:37 AM
how to run script from .bash_profile npatwardhan Shell Programming and Scripting 3 01-19-2009 12:24 AM
question in .bash_profile hannem Shell Programming and Scripting 1 08-01-2008 07:09 AM
.bash_profile problem nua7 Shell Programming and Scripting 0 06-12-2008 07:05 AM
numbers on permanently through .bash_profile zorrokan UNIX for Dummies Questions & Answers 3 08-22-2007 06:28 AM



All times are GMT -4. The time now is 07:50 AM.