Welcome to the Linux Foundation Forum!

Facing problem when logging in as "root"

Hai,

In slackware, even if I login as "root", the commands like "lsusb","ppp-go","startx" are not responding. If I give "su" then again tried with same commands means, its working.

Am facing this problem recently [ last one week]. Previously, it was straight away worked if I logged in as root. The things happening now are,

root#lsusb



root#su

root#lsusb

Comments

  • marc
    marc Posts: 647
    linustorvalds wrote:
    Hai,
    In slackware, even if I login as "root", the commands like "lsusb","ppp-go","startx" are not responding. If I give "su" then again tried with same commands means, its working.
    Am facing this problem recently [ last one week]. Previously, it was straight away worked if I logged in as root. The things happening now are,

    root#lsusb
    <nothing is coming. same for ppp-go and startx>
    root#su
    root#lsusb
    <it is listing the usb stuffs>

    What does "nothing is coming" mean? is it frozen? it just ends with no output?

    If, for any reason, the default output is broken you can try with
    lsusb > lsusb_output
    

    And check if there is in fact some output on the file

    Regards
  • chekkizhar
    chekkizhar Posts: 182
    What does "nothing is coming" mean? is it frozen? it just ends with no output?
    for lsusb and ppp-go, "Command not found" is coming.

    for "startx", it is trying to initiate the xserver, but it again come back to command line mode with error. [will post error, since now the system is not with me]

    I guess, am not getting the root permission even I logging in as root. But, if i give the command "su", it is not prompting for password but thereafter the commands are working fine.
  • mfillpot
    mfillpot Posts: 2,177
    It is pretty simple, due to some configuration change you made the PATH variable was not set, so your user shell does not know to look into /sbin, /bin, etc.. for commands.

    Did you change .bashrc, /etc/profile or any related files prior to the issue?
  • chekkizhar
    chekkizhar Posts: 182
    mfillpot wrote:
    so your user shell does not know to look into /sbin, /bin, etc.. for commands.

    may be. But, I am logging as root. Meanwhile, after "su" command with out asking for password the commands are working.
    after "su" , the shell can look into special binaries. But, why its not happening after I logged in as "root".

    I will check more with whoami kind of commands, and report it here tonight. [system not with me currently ]

    Did you change .bashrc, /etc/profile or any related files prior to the issue?

    yes for my device driver programming I added my path in bash_profile. But, I did not remove any thing or changed anything in that file. Just added my path.
  • mpalmeruk
    mpalmeruk Posts: 26
    I agree with mfillpot, and you could verify if that is the issue by specifying the absolute path to the binary as root. If it works, then thats what the issue is.

    regards

    Matt
  • marc
    marc Posts: 647
    mpalmeruk wrote:
    I agree with mfillpot, and you could verify if that is the issue by specifying the absolute path to the binary as root. If it works, then thats what the issue is.

    regards

    Matt

    I'll bet a beer that's the problem :)
    echo $PATH
    

    Logged in as root and after "su". You'll see the difference.

    Check /etc/profile and /etc/login.defs as well as /etc/bashrc or whatever files you might source on your login process.

    Regards
  • mfillpot
    mfillpot Posts: 2,177
    linustorvalds wrote:
    yes for my device driver programming I added my path in bash_profile. But, I did not remove any thing or changed anything in that file. Just added my path.[/quote]

    You hit the nail on the head. your modification in bash_profile would be the cause of the problems, the proper way to append an entry to the PATH variable would be:
    export PATH=$PATH:/new/path
    

    please confirm that you typed it correctly, if you did not then your new path is the only one what is available to the user, you can confirm the PATH variable by explicitly calling the echo command with:
    /usr/bin/echo $PATH
  • marc
    marc Posts: 647
    mfillpot wrote: the proper way to append an entry to the PATH variable would be:
    export PATH=$PATH:/new/path
    
    [/quote]

    I would even go further
    export PATH="$PATH":/new/path
    

    Notice the "

    :)

    Regards
  • chekkizhar
    chekkizhar Posts: 182

    Logged in as root and after "su". You'll see the difference.

    Check /etc/profile and /etc/login.defs as well as /etc/bashrc or whatever files you might source on your login process.

    Regards

    I checked in /etc/login.defs and in bash_profile before and after "su' command. NO difference in both files.

    Before I give "su", if i give the absolute path, "/sbin/lsusb" , it is listing the usb details. simple lsusb gives "command not found"

    Before and after "su" command the login.defs and bash_profile is same. And, the PATH variable I added some two months back[the moment i installed slackware]. It worked well so far. for the past few days only am facing.

    But, thanks to Mathew and deop for the PATH variable adding method hint. I did not know till see your posts.
  • marc
    marc Posts: 647
    I suggested to compare the $PATH variables under root and after "su", not the files (they will obviously be the same ;) ).

    Anyway, glad you could solve the issue :)

    Regards
  • chekkizhar
    chekkizhar Posts: 182
    what happened. For a long time offline mode.
    marc wrote:
    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
  • chekkizhar
    chekkizhar Posts: 182

    I would even go further
    export PATH="$PATH":/new/path
    

    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
  • marc
    marc Posts: 647
    linustorvalds wrote:
    what happened. For a long time offline mode.
    marc wrote:
    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

    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".
  • marc
    marc Posts: 647
    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
  • chekkizhar
    chekkizhar Posts: 182
    marc wrote:
    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
    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.

Categories

Upcoming Training