[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Unable to execute a script without asking for sudo password, even after editing sudoers file.



> The default ~/.profile on Debian already has:
>
>     # set PATH so it includes user's private bin if it exists
>     if [ -d "$HOME/bin" ] ; then
>         PATH="$HOME/bin:$PATH"
>     fi
>

I think I am really messed up in that situation. If I run 'echo $PATH'
in a terminal session then this is the output that I get:

/home/neo1691/bin:/home/neo1691/.rvm/gems/ruby-2.0.0-p451@railstutorial_rails_4_0/bin:/home/neo1691/.rvm/gems/ruby-2.0.0-p451@global/bin:/home/neo1691/.rvm/rubies/ruby-2.0.0-p451/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/neo1691/.rvm/bin:/home/neo1691/bin:/home/neo1691/.rvm/bin:/home/neo1691/.rvm/bin

As you can see there is a lot of repetition over there.

So to be precise, I first used my ~/.bashrc file to export the PATH variable.
export PATH=${PATH}:/home/neo1691/bin

I remember that when I did this, there was no file called .profile in my home
directory. As I can see now, there exists one maybe because I installed rvm
and maybe rvm created a .profile

Here are the contents of my ~/.profile

# ~/.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
    PATH="$HOME/bin:$PATH"
fi


PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting

I also saw that there is a  ~/.bash_profile whose contents are

[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile


[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" #
Load RVM into a shell session *as a function*


> Now you just have to make sure whatever method you use to start X is
> also sourcing ~/.environment.
>

There is no such file called ~/.environment

> Depends on what you want to achieve. Because you put $HOME/bin at the
> end of $PATH (instead of in front as ~/.environment does) a script with
> the same name in one of the other directories will take precedence over
> yours, which may or may not be what you want.

I created the script i3exit, and I believe that there is no such other script
by that name in the system

> [1] according to apt-file there is no 'i3exit' file in Debian.
Yes thats right!

Now I would really like to know as to what is the best
practice to export a PATH variable?

I mean as a linux user, I should know what happens when the
operating system boots? What files are read? What are the uses of
.xsession?
.xinitrc?
.profile?
.bash_profile?
.environment?
/etc/X11/Xsession?

And what changes when I use lightdm to startup my system?

And what again changes if I install replace my default shell
from bash to zsh?

Right now what is happening is that I am not able to run the
script i3exit with i3 window manager?

If I run this command:
`tr '\0' '\n' </proc/$(pidof i3)/environ | grep PATH`

I get the output as:
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

And there is no mention of my local bin directory (~/bin)

So please guide me in this regards!

-- 
Regards,
Anubhav Yadav
Imperial College of Engineering and Research,
Pune.


Reply to: