Where are my bash_profile and bash_login/logout files?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Where are my bash_profile and bash_login/logout files?
# 1  
Old 03-09-2010
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?
# 2  
Old 03-10-2010
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
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
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
Quote:
Originally Posted by jhullbuzz
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
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 stuffSmilie
# 7  
Old 03-22-2010
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.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

Renaming .bash_profile to .profile

Hi Gurus, Recently we have migrated our servers from AIX to Linux. Most of the scripts written in AIX server are sourcing environment variables using .profile file. Now we have the following options: 1. Change all the scripts where ever .profile is being used and replace it with... (14 Replies)
Discussion started by: svajhala
14 Replies

2. UNIX for Dummies Questions & Answers

.bash_profile question

Hello everyone, I'm trying to set my .bash_profile to change my primary prompt from this: banbatchtest1v:MCPPRD:~>to this: banbatchtest1v:MCPPRD:/home/rcarvall> Here's what my .bash_profile looks like right now: # .bash_profile # Get the aliases and functions if ; then .... (2 Replies)
Discussion started by: galileo1
2 Replies

3. Red Hat

.bash_profile file corrupted

Hi, Unexpectedly i entered wrong entries in .bash_profile for my user which has administrative permissions. So, i am getting errors for every command. I dont have backup file also, so any body can help me how to recover it. Regards, Mastan (7 Replies)
Discussion started by: mastansaheb
7 Replies

4. Shell Programming and Scripting

Add Variable in .bash_profile

Hi, I wanted to do the following, but the command does not seem to work. Any ideas or suggestions please help. #1. If the particular ENV variable IMPACT_HOME is not there in a file grep -q IMPACT_HOME infile || sed -i 'i IMPACT_HOME=/my/new/path' infile #2. If the ENV variable... (4 Replies)
Discussion started by: dbashyam
4 Replies

5. UNIX for Advanced & Expert Users

bash_profile or .profile

Hi, happy new year. on AIX 6.1 , for user oracle , there are two files : bash_profile and .profile I do not know which one is executed when login ? How to know , More over in both of them we have : in .profile : ORACLE_HOME=/appli/oracle/product/10.2.0/db_1... (5 Replies)
Discussion started by: big123456
5 Replies

6. Solaris

allias in .bash_profile not working

I am using solaris 10 x86. I have created a .bash_profile under root's home directory(/). The contents of the file are: Solaris10u8/# cat .bash_profile export PATH=$PATH:/usr/sfw/bin export PS1='\h\w\$ ' export PAGER="less -imsq" alias ll='ls -l' alias la='ls -a' The problem is that: ... (7 Replies)
Discussion started by: proactiveaditya
7 Replies

7. UNIX for Dummies Questions & Answers

bash_profile does not working

Hi all. when i connect as user megaguru i have a problem my .bash_profile does not working^:( if i do: . ./.bash_profile all enviroment variables are in place. How can i force linux to use .bash_profile before logon process? thanx in advance. (1 Reply)
Discussion started by: smallman
1 Replies

8. Shell Programming and Scripting

question in .bash_profile

We are more users using the oracle account, and people want to include theyr own files in .bash_profile. Like this: while ; do echo -n "LOGNAME is '$LOGNAME' (no sens), who are you? " >/dev/stderr read ln export LOGNAME=$ln done This works well when logging in to... (1 Reply)
Discussion started by: hannem
1 Replies

9. Shell Programming and Scripting

.bash_profile problem

Hi Guys, I modified my .bash_profile script , and tried to change the prompt. Following is the line of code in my .bash_profile script. export PS1=" \W " But I get the output as: \W This appears to be my prompt now. Any idea what should be done.. Thanks! (0 Replies)
Discussion started by: nua7
0 Replies

10. UNIX for Advanced & Expert Users

.bash_profile access related.

1.If a user adds the logout command in the .bash_profile file, then that user cant login.(I hope I'm correct) So, is there anyway to login into that users account without contacting the root or an administrator. 2. Is there anyway to execute a command in remote machine rsh and uux seem to fail... (6 Replies)
Discussion started by: sriram_r
6 Replies
Login or Register to Ask a Question