LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Need help about bash profile file. (https://www.linuxquestions.org/questions/linux-newbie-8/need-help-about-bash-profile-file-793317/)

gardenair 03-04-2010 11:27 PM

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

evo2 03-04-2010 11:32 PM

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.

catkin 03-04-2010 11:35 PM

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.

gardenair 03-04-2010 11:56 PM

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 ?

evo2 03-05-2010 12:02 AM

Quote:

Originally Posted by gardenair (Post 3886514)
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.

gardenair 03-05-2010 12:47 AM

thanks a lot for your help.

onebuck 03-05-2010 07:50 AM

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!


All times are GMT -5. The time now is 01:44 AM.