Linux.com

Home Linux Community Forums Linux Distributions Slackware Facing problem when logging in as "root"

Facing problem when logging in as "root"

Link to this post 30 Jun 11



I would even go further

[code]export PATH="$PATH":/new/path[/code]

Notice the "

:)

Regards

I have one doubt.
$ symbol, itself a decoder . After that , adding " " is adding any further things? When we must use the " " ?
thanks

Link to this post 30 Jun 11

linustorvalds wrote:

what happened. For a long time offline mode.
[b]marc wrote:[/b]
[quote]I suggested to compare the $PATH variables under root and after "su", not the files (they will obviously be the same ;) ).

ok. I will compare that.

still my doubt is,

I am logging in as root and the shell supposed to load root's profile only, right ?
"su" is also doing the same, [ logging in as root and loading the user's profile variables ], right ? or any other added things are carried out?

thanks, Good day[/quote]

Nope, it's not the same.

Depending on your distro's config you'll get different environments whenever you log in by root or scaling privileges by "su".

Link to this post 30 Jun 11

linustorvalds wrote:



I have one doubt.
$ symbol, itself a decoder . After that , adding " " is adding any further things? When we must use the " " ?
thanks

$var is used to tell the shell to "expand" what's inside that variable.

One problem kicks in whenever blank spaces are in that variable. As bash (and most shells) works in "words"... how do we separate words? Bash uses blank spaces for that.... ( you can change that behaveour with the IFS variable though). What would happen if you have something like "/usr/my bin folder/" and you would like that to be in your path?


PATH=/usr/my bin folder/

Bash would see:

"PATH=/usr/my" "bin" "folder/"

and try to run the "bin" with a "folder/" after setting the PATH variable to "/usr/my" parameter ala running

ls /home

With the "" symbols we are telling bash that everything is a *word* therefore the "my bin folder" will be in our PATH :)

Have I explained myself? :S

Regards

Link to this post 30 Jun 11

marc wrote:

[b]linustorvalds wrote:[/b]
[quote]

I have one doubt.
$ symbol, itself a decoder . After that , adding " " is adding any further things? When we must use the " " ?
thanks

$var is used to tell the shell to "expand" what's inside that variable.

One problem kicks in whenever blank spaces are in that variable. As bash (and most shells) works in "words"... how do we separate words? Bash uses blank spaces for that.... ( you can change that behaveour with the IFS variable though). What would happen if you have something like "/usr/my bin folder/" and you would like that to be in your path?


PATH=/usr/my bin folder/

Bash would see:

"PATH=/usr/my" "bin" "folder/"

and try to run the "bin" with a "folder/" after setting the PATH variable to "/usr/my" parameter ala running

ls /home

With the "" symbols we are telling bash that everything is a *word* therefore the "my bin folder" will be in our PATH :)

Have I explained myself? :S

Regards[/quote]
I guess, this will work,

" PATH=/usr/my\\ bin\\ folder/ "

but, i agree, " " is a simple way to get rid of with the escape sequence character. Even, i tried the above "PATH=/usr/my\ bin\ folder/ " inside code section, which came as,


PATH=/usr/my\ bin\ folder/
:ohmy:

need to use two escape sequence chars.

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board