Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 


    gedit ~/.bashrc 


    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:


My echo $ PATH in sudo su gives:


@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

# 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)

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm-color) color_prompt=yes;;

# 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

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.)

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"

# 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'

# 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

# 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

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
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 – IS_Eagle_NG Apr 17 '13 at 8:24

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

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? – IS_Eagle_NG 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

Your Answer


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.