maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Nokia N810 (https://talk.maemo.org/forumdisplay.php?f=28)
-   -   where to add new dirs to PATH? (https://talk.maemo.org/showthread.php?t=26696)

leohart 2009-02-07 15:07

where to add new dirs to PATH?
 
hi,the /sbin is not in PATH on N810, so I cannot use command like ifconfig, I've tried vi .bashrc in my home dir, but it doesnt work(the .bashrc is not sourced automatically when bash2 startup)
so what should I do next?

ps: I have installed bash2, and it always shows full path before the prompt, this is really annoying when the path is very long, how can I make only the last dir is shown like a normal shell always does?
THX

qwerty12 2009-02-07 15:16

Re: where to add new dirs to PATH?
 
echo "PATH=/sbin:$PATH" >> ~/.profile

^ should work.

As for your second question, look at the file /etc/profile.d/prompt.sh and google bash PS1.

Corrected thanks to free here:
http://www.internettablettalk.com/fo...73&postcount=4 :)

free 2009-02-07 15:29

Re: where to add new dirs to PATH?
 
Read man bash, section INVOCATION:

* bashrc is not sourced for interactive login shells, only for non-login shells
* profile is source for interfactive login shells


As everything inherits from login shells, the place for $PATH setting is in a profile file (/etc/profile, /etc/bash_profile or ~/.profile, ~/.bash_profile)

Then some distributions do not follow this, they source .bashrc within .profile but it's not a general rule.

free 2009-02-07 15:32

Re: where to add new dirs to PATH?
 
Quote:

Originally Posted by qwerty12 (Post 262766)
echo "/sbin:$PATH" >> ~/.profile

Hi qwerty12!

I guess you meant

echo "PATH=/sbin:$PATH" >> ~/.profile

leohart 2009-02-07 15:41

Re: where to add new dirs to PATH?
 
Quote:

Originally Posted by free (Post 262770)
Read man bash, section INVOCATION:

* bashrc is not sourced for interactive login shells, only for non-login shells
* profile is source for interfactive login shells


As everything inherits from login shells, the place for $PATH setting is in a profile file (/etc/profile, /etc/bash_profile or ~/.profile, ~/.bash_profile)

Then some distributions do not follow this, they source .bashrc within .profile but it's not a general rule.

I just used to edit .bashrc under centos and it works fine ,so I dont know these stuff...
but I didnt login when I opened a xterminal, why it is a interactive login shell?

leohart 2009-02-07 15:50

Re: where to add new dirs to PATH?
 
Quote:

Originally Posted by qwerty12 (Post 262766)
echo "/sbin:$PATH" >> ~/.profile

^ should work.

As for your second question, look at the file /etc/profile.d/prompt.sh and google bash PS1.

thank you so much:)

free 2009-02-07 15:55

Re: where to add new dirs to PATH?
 
Quote:

Originally Posted by leohart (Post 262776)
I just used to edit .bashrc under centos and it works fine ,so I dont know these stuff...
but I didnt login when I opened a xterminal, why it is a interactive login shell?

That's what I said, some distro do their internal cooking, when you change distro, it does not work anymore.
Why I use debian on all my machines..

When you open a terminal, it has inherited the variable PATH from the login shell.

free 2009-02-07 15:57

Re: where to add new dirs to PATH?
 
Put this in bashrc and open a terminal, open another one within this one.
Look at your PATH, it contains two times /sbin
;)

leohart 2009-02-07 16:18

Re: where to add new dirs to PATH?
 
excuse me ,just curious,how can I open another terminal within a terminal?
tried osso-xterm but it doesnt work...

free 2009-02-07 16:57

Re: where to add new dirs to PATH?
 
Sorry, I was talking in general on unix/linux machines.

I don't know for the device. BUt you can can open a new tab.

statwrangler 2010-01-05 18:20

Re: where to add new dirs to PATH?
 
Quote:

Originally Posted by qwerty12 (Post 262766)
echo "PATH=/sbin:$PATH" >> ~/.profile

^ should work.

As for your second question, look at the file /etc/profile.d/prompt.sh and google bash PS1.

Corrected thanks to free here:
http://www.internettablettalk.com/fo...73&postcount=4 :)

For those searching for "N900 $PATH", I add: After much reading and some courage I added "/home/user/bin" using the above. (((There was no /home/user/.profile so I created it with text: "PATH = $PATH:/user/home/bin"))). It works. I can now safely run some little shell scripts (stored in /home/user/bin which I created for this purpose) as user. Thanks querty12.

fatalsaint 2010-01-05 18:27

Re: where to add new dirs to PATH?
 
Just because I'm on of those attention to detail idiots...

You'll notice in qwerty's he put the added path before the $PATH:
Code:

/sbin:$PATH
And you put yours after the $PATH:
Code:

$PATH:/user/home/bin
99.99% of the time this will never matter. However, that IS order sensitive... if you have two applications on the system with the same name in two different paths, the first one it comes to in your $PATH variable will be the one executed. So, just for example, you write a wrapper for VI or something that enables colors or uses VIM or other command line options and store it as "vi".. put it in ~/bin and then put that after $PATH.. it'll never run.

Like I said... 99.99% of the time it'll never matter.. but there can be uses for understanding this.

statwrangler 2010-01-05 20:00

Re: where to add new dirs to PATH?
 
You are right that the order matters. My choice of after was deliberate. I can always change the name of my script (e.g. myvi). I will know immediately if I have picked a name used by the shell. But if I put my bin first, I might pick a common name and much later find that the standard procedure was not available -- and having forgotten my script, be puzzled. De gustibus ....


All times are GMT. The time now is 17:47.

vBulletin® Version 3.8.8