Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230
Where is .bash_profile file or his equivalent?
Where is .bash_profile file or his equivalent?
Hi, I want to ask you where is .bash_profile file or his equivalent? I want to change variable PATH. In Fedora distro was in home directoty file .bash_profile in which was variable PATH. I could change PATH in this file... But in Debian I cant find this file. Can you advise me where change PATH? Thanks
- Telemachus
- Posts: 4574
- Joined: 2006-12-25 15:53
- Been thanked: 2 times
Re: Where is .bash_profile file or his equivalent?
If you do ls -A, you should have both a .bashrc and a .profile. You probably want to edit .bashrc instead. Both .profile and .bash_profile are for login shells, and depending on what you do, many of your shells (in an X environment) will be non-login shells. The good news is that by default Debian's .profile automatically sources .bashrc, so anything you put in .bashrc gets sourced either way.
"We have not been faced with the need to satisfy someone else's requirements, and for this freedom we are grateful."
Dennis Ritchie and Ken Thompson, The UNIX Time-Sharing System
Dennis Ritchie and Ken Thompson, The UNIX Time-Sharing System
-
- Posts: 1740
- Joined: 2009-05-04 15:56
- Been thanked: 1 time
Re: Where is .bash_profile file or his equivalent?
To explain why you might like to know that bash will source .profile if .bash_profile does not exist, and other shells will source .profile, while only bash will us .bash_profile, so using .profile allows configuration for other shells to be set as well.
Re: Where is .bash_profile file or his equivalent?
I use Bash... I looked to .profile and I found there the following line PATH="$HOME/bin:$PATH". Do I understand correct that in variable PATH is saved path to the home directory and bin directory? I dont understand what does mean $PATH on the end of this line.
Re: Where is .bash_profile file or his equivalent?
A colon (:) is the separator character in *nix, so what that statement does is add $HOME/bin to the existing value of $PATH.mono wrote:I use Bash... I looked to .profile and I found there the following line PATH="$HOME/bin:$PATH". Do I understand correct that in variable PATH is saved path to the home directory and bin directory? I dont understand what does mean $PATH on the end of this line.
In other words: the new PATH is $HOME/bin + the old PATH
Re: Where is .bash_profile file or his equivalent?
Ok but when I added new directory(sbin) into PATH: PATH="$HOME/bin:/sbin:$PATH" and then I figured variable PATH so I got the following statement bash: /usr/local/bin:/usr/bin:/bin:/usr/games:. sbin is not in PATH. How can I add new directoty into PATH?
- Telemachus
- Posts: 4574
- Joined: 2006-12-25 15:53
- Been thanked: 2 times
Re: Where is .bash_profile file or his equivalent?
After you add the new directory, you have to either log out and log back in or re-source whatever file you edited. So, let's assume you are editing the $PATH in .profile. After you finish your editing, do this:mono wrote:Ok but when I added new directory(sbin) into PATH: PATH="$HOME/bin:/sbin:$PATH" and then I figured variable PATH so I got the following statement bash: /usr/local/bin:/usr/bin:/bin:/usr/games:. sbin is not in PATH. How can I add new directoty into PATH?
Code: Select all
. .profile
"We have not been faced with the need to satisfy someone else's requirements, and for this freedom we are grateful."
Dennis Ritchie and Ken Thompson, The UNIX Time-Sharing System
Dennis Ritchie and Ken Thompson, The UNIX Time-Sharing System
Re: Where is .bash_profile file or his equivalent?
I did like you said, but my $PATH looks still same. I wrote to .profile PATH="$HOME/bin:/sbin:/bin:/home" but when I display variable PATH so I see the following: bash: /usr/local/bin:/usr/bin:/bin:/usr/games:
-
- Posts: 1740
- Joined: 2009-05-04 15:56
- Been thanked: 1 time
Re: Where is .bash_profile file or his equivalent?
I think you are missing the export statement. should give you what you want. Your $HOME/bin will be added by .bashrc if you have not changed that file and if $HOME/bin exists. It will also be added at the end of your path which is almost always better.
Code: Select all
export PATH=$PATH:/sbin
- Telemachus
- Posts: 4574
- Joined: 2006-12-25 15:53
- Been thanked: 2 times
Re: Where is .bash_profile file or his equivalent?
I doubt that's the problem since export is not required in this case. All I have in my .profile is this, and it works like a charm:smallchange wrote:I think you are missing the export statement.should give you what you want. Your $HOME/bin will be added by .bashrc if you have not changed that file and if $HOME/bin exists. It will also be added at the end of your path which is almost always better.Code: Select all
export PATH=$PATH:/sbin
Code: Select all
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
Code: Select all
cat .profile .bashrc
"We have not been faced with the need to satisfy someone else's requirements, and for this freedom we are grateful."
Dennis Ritchie and Ken Thompson, The UNIX Time-Sharing System
Dennis Ritchie and Ken Thompson, The UNIX Time-Sharing System
-
- Posts: 1740
- Joined: 2009-05-04 15:56
- Been thanked: 1 time
Re: Where is .bash_profile file or his equivalent?
You are right about the export. PATH is a reserved variable in bash that is automatically exported as part of the environment.
Re: Where is .bash_profile file or his equivalent?
Here are exports from profile and bashrc.
cat .profile .bashrc
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
umask 022
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
#originally
# PATH="$HOME/bin:$PATH"
#newly added
PATH="$HOME/bin:/sbin:/bin:/home"
fi
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
# don't overwrite GNU Midnight Commander's setting of `ignorespace'.
export HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoredups
# ... or force ignoredups and ignorespace
export HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# make less more friendly for non-text input files, see lesspipe(1)
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
#if [ -f ~/.bash_aliases ]; then
# . ~/.bash_aliases
#fi
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
eval "`dircolors -b`"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
#alias grep='grep --color=auto'
#alias fgrep='fgrep --color=auto'
#alias egrep='egrep --color=auto'
fi
# some more ls aliases
#alias ll='ls -l'
#alias la='ls -A'
#alias l='ls -CF'
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
polo@debian:~$ export PATH=$PATH:/sbinexport PATH=$PATH:/sbin
cat .profile .bashrc
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
umask 022
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
#originally
# PATH="$HOME/bin:$PATH"
#newly added
PATH="$HOME/bin:/sbin:/bin:/home"
fi
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
# don't overwrite GNU Midnight Commander's setting of `ignorespace'.
export HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoredups
# ... or force ignoredups and ignorespace
export HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# make less more friendly for non-text input files, see lesspipe(1)
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
#if [ -f ~/.bash_aliases ]; then
# . ~/.bash_aliases
#fi
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
eval "`dircolors -b`"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
#alias grep='grep --color=auto'
#alias fgrep='fgrep --color=auto'
#alias egrep='egrep --color=auto'
fi
# some more ls aliases
#alias ll='ls -l'
#alias la='ls -A'
#alias l='ls -CF'
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
polo@debian:~$ export PATH=$PATH:/sbinexport PATH=$PATH:/sbin
- Telemachus
- Posts: 4574
- Joined: 2006-12-25 15:53
- Been thanked: 2 times
Re: Where is .bash_profile file or his equivalent?
A few things:
- Please wrap quotations like this in code tags. It makes it much easier to read since those tags preserve indentation.
- You have your new $PATH setting inside an if test that may not be true. It says, "Make this my new path if I have a directory called 'bin' in my home directory." Do you have such a directory? (You can check with ls if you're not sure. An answer to this problem is to move your new $PATH setting below the if...fi structure:
Code: Select all
# set PATH so it includes user's private bin if it exists if [ -d "$HOME/bin" ] ; then #originally # PATH="$HOME/bin:$PATH" #newly added ## REMOVE THIS -- PATH="$HOME/bin:/sbin:/bin:/home" fi # Put the $PATH below here PATH="$HOME/bin:/sbin:/bin:/home"
- Finally, the path you are trying to set is very odd. You aren't giving yourself access to /usr/bin or /usr/local, both of which are pretty normal places to find software. (I have around 1800 executables in /usr/bin as an example.) On the other hand, do you really expect to install software in /home?
"We have not been faced with the need to satisfy someone else's requirements, and for this freedom we are grateful."
Dennis Ritchie and Ken Thompson, The UNIX Time-Sharing System
Dennis Ritchie and Ken Thompson, The UNIX Time-Sharing System
Re: Where is .bash_profile file or his equivalent?
Code: Select all
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
#originally
# PATH="$HOME/bin:/sbin:$PATH"
fi
#newly write
PATH="$HOME/bin:/sbin:/bin:"
- Telemachus
- Posts: 4574
- Joined: 2006-12-25 15:53
- Been thanked: 2 times
Re: Where is .bash_profile file or his equivalent?
First, you should remove the final ':' from the $PATH setting. Second, have you logged into a new shell or resourced your .profile? Try this:mono wrote:No, I dont expect that I will install SW from home. It was just test directory. Problem is still here. Look at my code and look what display env command:PATH=/usr/local/bin:/usr/bin:/bin:/usr/games. The PATH is still the same:(Code: Select all
# set PATH so it includes user's private bin if it exists if [ -d "$HOME/bin" ] ; then #originally # PATH="$HOME/bin:/sbin:$PATH" fi #newly write PATH="$HOME/bin:/sbin:/bin:"
Code: Select all
source ~/.profile
echo $PATH
"We have not been faced with the need to satisfy someone else's requirements, and for this freedom we are grateful."
Dennis Ritchie and Ken Thompson, The UNIX Time-Sharing System
Dennis Ritchie and Ken Thompson, The UNIX Time-Sharing System
Re: Where is .bash_profile file or his equivalent?
source ~/.profile
bash: /home/polo/.profile: line 26: syntax error near unexpected token `fi'
bash: /home/polo/.profile: line 26: `fi'
Correct PATH: PATH="$HOME/bin:/sbin:/bin"
bash: /home/polo/.profile: line 26: syntax error near unexpected token `fi'
bash: /home/polo/.profile: line 26: `fi'
Correct PATH: PATH="$HOME/bin:/sbin:/bin"
- Telemachus
- Posts: 4574
- Joined: 2006-12-25 15:53
- Been thanked: 2 times
Re: Where is .bash_profile file or his equivalent?
Ok, so back on page one of this thread, when I wrote this, you skipped the key step:mono wrote: source ~/.profile
bash: /home/polo/.profile: line 26: syntax error near unexpected token `fi'
bash: /home/polo/.profile: line 26: `fi'
Correct PATH: PATH="$HOME/bin:/sbin:/bin"
You should also clean up your .profile so that you don't get that error message every time that you login.Telemachus wrote:After you finish your editing, do this:
The command . sources the .profile file again. After that, you should see the updated $PATH variable.Code: Select all
. .profile
"We have not been faced with the need to satisfy someone else's requirements, and for this freedom we are grateful."
Dennis Ritchie and Ken Thompson, The UNIX Time-Sharing System
Dennis Ritchie and Ken Thompson, The UNIX Time-Sharing System
Re: Where is .bash_profile file or his equivalent?
I didnt skip this step. When I do . .profile
then I get...
bash: .profile: line 26: syntax error near unexpected token `fi'
bash: .profile: line 26: `fi'
then I get...
bash: .profile: line 26: syntax error near unexpected token `fi'
bash: .profile: line 26: `fi'
- Telemachus
- Posts: 4574
- Joined: 2006-12-25 15:53
- Been thanked: 2 times
Re: Where is .bash_profile file or his equivalent?
Put # marks in front of the whole if block, so that it looks like this:mono wrote:I didnt skip this step. When I do . .profile
then I get...
bash: .profile: line 26: syntax error near unexpected token `fi'
bash: .profile: line 26: `fi'
Code: Select all
# set PATH so it includes user's private bin if it exists
#if [ -d "$HOME/bin" ] ; then
#originally
# PATH="$HOME/bin:/sbin:$PATH"
#fi
"We have not been faced with the need to satisfy someone else's requirements, and for this freedom we are grateful."
Dennis Ritchie and Ken Thompson, The UNIX Time-Sharing System
Dennis Ritchie and Ken Thompson, The UNIX Time-Sharing System
Re: Where is .bash_profile file or his equivalent?
It works Telemachus!:) Thank you very much and sorry for my stupidity.