LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-04-2010, 11:27 PM   #1
gardenair
Member
 
Registered: Oct 2004
Location: LH
Posts: 648

Rep: Reputation: 45
Need help about bash profile file.


Hi,
I want to know the difference between the following files

1- .bash_profile
2- .bashrc
3- .bash_logout

These three files are located in with their respective names under the following dir

/etc/skel
/home/user1


Further when i login into terminal i see the login prompt as
[user1@localhost user1]$

I want that when user2 will login he automatically login into
[user1@localhost /]$

the output when i use
[user1@localhost user1]$cat .bash_profile
------------------------------------------------------------------
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin:

export PATH
unset USERNAME

----------------------------------------------------------------


Please guide me.Thanks in advance.
mypass
 
Old 03-04-2010, 11:32 PM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
These files are described in the bash man page:

Code:
       ~/.bash_profile
              The personal initialization file, executed for login shells
       ~/.bashrc
              The individual per-interactive-shell startup file
       ~/.bash_logout
              The individual login shell cleanup file, executed when a login shell exits
When a new user account is created, any files in /etc/skel/ get copied to the new users home dir.

Evo2.
 
Old 03-04-2010, 11:35 PM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
The Bash startup files are explained here.

The /etc/skel files are used when setting up a new user. Any files in /etc/skel are copied to the new users home directory. More info in the useradd (and adduser?) man page.

The command prompt is configured using the $PS1 variable, set in the Bash startup files. Special characters used in PS1 are described here.
 
Old 03-04-2010, 11:56 PM   #4
gardenair
Member
 
Registered: Oct 2004
Location: LH
Posts: 648

Original Poster
Rep: Reputation: 45
thanks for the prompt reply. well i am new in linux. just tell me how can i change

PATH=$PATH:$HOME/bin:

so i may see the login prompt of user2 as [user1@localhost /]$

where may i edit the path ?
 
Old 03-05-2010, 12:02 AM   #5
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Quote:
Originally Posted by gardenair View Post
thanks for the prompt reply. well i am new in linux. just tell me how can i change

PATH=$PATH:$HOME/bin:

so i may see the login prompt of user2 as [user1@localhost /]$

where may i edit the path ?
The PATH and login prompt are completely unrelated. If you want to modify the login prompt you need to set the PS1 variable. There are a huge number of tutorials on this topic on the web. For example, this was the first hit when I googled:

bash howto set prompt

http://www.cyberciti.biz/tips/howto-...up-prompt.html

Evo2.
 
Old 03-05-2010, 12:47 AM   #6
gardenair
Member
 
Registered: Oct 2004
Location: LH
Posts: 648

Original Poster
Rep: Reputation: 45
thanks a lot for your help.
 
Old 03-05-2010, 07:50 AM   #7
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Hi,

You could setup a .bashrc & .bash_profile for your user, maybe a sample will aid;

Code:
sample .bash_profile;

~$ cat .bash_profile
# .bash_profile
#08-30-06 12:21
#
# Source .bashrc
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
Code:
sample .bashrc;
:~$ cat .bashrc

#.bashrc
#08-30-06 12:20 

# Add bin to path

export PATH="$PATH:/sbin:/usr/sbin:$HOME/bin"

#export PATH="$PATH:$HOME/bin"

# Dynamic resizing
shopt -s checkwinsize

# Custom prompt
#PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

#08-29-06 11:40

if [ `id -un` = root ]; then
   PS1='\[\033[1;31m\]\h:\w\$\[\033[0m\] '
 else
   PS1='\[\033[1;32m\]\h:\w\$\[\033[0m\] '
fi

#
# Add color
eval `dircolors -b`

# User defined aliases
alias cls='clear'
alias clls='clear; ls'
alias ll='ls -l'
alias lsa='ls -A'
alias lsg='ls | grep'
alias lsp='ls -1 /var/log/packages/ > package-list'
alias na='nano'
alias web='links -g -download-dir ~/ www.google.com'

#08-29-06 11:50

#To clean up and cover your tracks once you log off
#Depending on your version of BASH, you might have to use
# the other form of this command
   trap "rm -f ~$LOGNAME/.bash_history" 0

#The older KSH-style form
#   trap 0 rm -f ~$LOGNAME/.bash_history
The .bashrc is very useful!

Plus as others have stated you can always 'man bash' to get some understanding.

Look at these useful links;

Linux Documentation Project
Rute Tutorial & Exposition
Linux Command Guide
Linux Newbie Admin Guide
LinuxSelfHelp
Getting Started with Linux

These links and others can be found at 'Slackware-Links' .
More than just SlackwareŽ links!
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Slackware bash profile ibwew Slackware 10 09-13-2009 12:36 PM
Bash Profile ...... babujd Linux - Newbie 16 07-23-2009 06:25 PM
Erasing the bash profile? AQG Linux - Security 6 07-06-2005 03:31 PM
bash and user profile maxoo Slackware 1 08-05-2004 06:19 AM
where is my bash profile? bandofmercy Linux - General 3 04-08-2003 05:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration