Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Please which one of these should I edit to give me required result of the path to my programs both in normal user and as root. I have added in normal user and as root but there is error as quoted below. I read in one of the Ubuntu environment sites that pam_environment is now to be used. But how do I use it to add the path for ns 2.35 and OMNET++? I have edited some of them but it not working. Thanks! Should I use:

    gedit ~/.profile 

or

    gedit ~/.bashrc 

or

    gedit ~/.pam_environment

I seems to have messed up some of them while I was try to use them to add the path of my ns and OMNET. Both program were running a week ago but now its having this errors. I need to use any of these, my ns 2.35 is having this error:

The program 'ns' is currently not installed.  You can install it by typing:
sudo apt-get install ns2

Omnettpp also gives the same error. My echo $ PATH in sudo su gives:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/sbin:/root/johna/omnetpp-4.2.2/bin:/root/johna/ns-allinone-2.35/bin:/root/johna/ns-allinone-2.35/tcl8.5.10/unix:/root/johna/ns-allinone-2.35/tk8.5.10/unix:/root/johna/omnetpp-4.2.2/bin:/root/johna/ns-allinone-2.35/bin:/root/johna/ns-allinone-2.35/tcl8.5.10/unix:/root/johna/ns-allinone-2.35/tk8.5.10/unix:/root/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/sbin:/root/johna/omnetpp-4.2.2/bin:/root/johna/ns-allinone-2.35/bin:/root/johna/ns-allinone-2.35/tcl8.5.10/unix:/root/johna/ns-allinone-2.35/tk8.5.10/unix:/root/johna/omnetpp-4.2.2/bin:/root/johna/ns-allinone-2.35/bin:/root/johna/ns-allinone-2.35/tcl8.5.10/unix:/root/johna/ns-allinone-2.35/tk8.5.10/unix:/root/johna/omnetpp-4.2.2/bin:/root/johna/ns-allinone-2.35/bin:/root/johna/ns-allinone-2.35/tcl8.5.10/unix:/root/johna/ns-allinone-2.35/tk8.5.10/unix

My echo $ PATH in sudo su gives:

/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/sbin:/root/johna/omnetpp-4.2.2/bin:/root/johna/ns-allinone-2.35/bin:/root/johna/ns-allinone-2.35/tcl8.5.10/unix:/root/johna/ns-allinone-2.35/tk8.5.10/unix:/root/johna/omnetpp-4.2.2/bin:/root/johna/ns-allinone-2.35/bin:/root/johna/ns-allinone-2.35/tcl8.5.10/unix:/root/johna/ns-allinone-2.35/tk8.5.10/unix:/home/johna/johna/omnetpp-4.2.2/bin:/home/johna/johna/ns-allinone-2.35/bin:/home/johna/johna/ns-allinone-2.35/tcl8.5.10/unix:/home/johna/johna/ns-allinone-2.35/tk8.5.10/unix:/home/johna/johna/omnetpp-4.2.2/bin:/home/johna/johna/ns-allinone-2.35/bin:/home/johna/johna/ns-allinone-2.35/tcl8.5.10/unix:/home/johna/johna/ns-allinone-2.35/tk8.5.10/unix

@Selam thanks for your input please this is the output of this as shown below. Is it correct or there are errors that I have made?

    root@MQMK-Lenovo-G555:/home/johna# gedit ~/.bashrc
# ~/.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
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

# 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

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || 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 -alF'
alias la='ls -A'
alias l='ls -CF'

# 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 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 ] && ! shopt -oq posix; then
    . /etc/bash_completion
fi

export PATH=$PATH:$HOME/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/sbin:/root/johna/omnetpp-4.2.2/bin:/root/johna/ns-allinone-2.35/bin:/root/johna/ns-allinone-2.35/tcl8.5.10/unix:/root/johna/ns-allinone-2.35/tk8.5.10/unix:/root/johna/omnetpp-4.2.2/bin:/root/johna/ns-allinone-2.35/bin:/root/johna/ns-allinone-2.35/tcl8.5.10/unix:/root/johna/ns-allinone-2.35/tk8.5.10/unix

export PATH=$PATH:$HOME/johna/omnetpp-4.2.2/bin
export TCL_LIBRARY=/usr/share/tcltk/tcl8.5
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/johna/omnetpp-4.2.2/lib
export LD_LIBRARY_PATH=/home/johna/omnetpp-4.2.2/lib

export PATH=$PATH:$HOME/johna/ns-allinone-2.35/bin
export PATH=$PATH:$HOME/johna/ns-allinone-2.35/tcl8.5.10/unix
export PATH=$PATH:$HOME/johna/ns-allinone-2.35/tk8.5.10/unix
export LD_LIBRARY_PATH=/home/johna/ns-allinone-2.35/lib
export LD_LIBRARY_PATH=/home/johna/ns-allinone-2.35/otcl-1.14
export TCL_LIBRARY=/home/johna/ns-allinone-2.35/tcl8.5.10/library
share|improve this question
5  
your question seems very unclear (at least for me). You should revise it. Also you claim there are two different outputs for the same command. Also: what are you trying to achieve? What is not working? If you need to edit such text files, you can use other editors like nano or vi as well, if there's a problem with gedit. As said before: your question seems totally unclear at this point. –  onse Apr 17 '13 at 7:54
    
@onse thanks I have done some edit –  forgoodGOD Apr 17 '13 at 8:24
add comment

1 Answer

It depends what you want to achieve.

profile files are executed when you login in a shell (ie: when you login in tty1 or by SSH, for example), while bashrc files are executed only when starting an interactive shell (open a new terminal, for example) and are only read by bash (the default shell).

So if you will be using those applications locally and in an interactive terminal ("Terminal" app) you can set $PATH in bashrc.

Also note that .bashrc/.profile are only used by your current user. So if you use sudo you get the correct behavior, but if you use other user, the PATH would not be modified:

➜  sudo -i
[sudo] password for <username>: 
root@Salem:~# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

If you want that to be added system-wide (in the PATH of every user), the correct files to edit should be /etc/profile and /etc/bash.bashrc.

Hope it helps.

share|improve this answer
    
@ Salem. thanks. I added some lines of the bashrc. Is it right? –  forgoodGOD Apr 17 '13 at 13:33
    
You probably don't need all those entries. If that doesn't work try adding an element to the path and try if everything works each time. Also, there is no need to use sudo to edit your own files. –  Salem Apr 17 '13 at 14:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.