Find the answer to your Linux question:
Results 1 to 10 of 10
Hey guys: I am having a bash_profile issue. When I log in as JohnDoe, then issue the command "su root" I am suppose to have root privileges. I probably do, ...
  1. #1
    Just Joined! Shutdown's Avatar
    Join Date
    Aug 2009
    Location
    New York
    Posts
    70

    Bash profile

    Hey guys:

    I am having a bash_profile issue.

    When I log in as JohnDoe, then issue the command "su root" I am suppose to have root privileges.

    I probably do, however it seems I am still in the "bash profile" environment of JohnDoe.

    So if I want to issue this command as root: chkconfig --list

    It says: command not found

    But if I log out completely, then log in as root, I can run that command.

    What is the point of issuing "SU" if you're not able to run commands as root user?

  2. #2
    Blackfooted Penguin daark.child's Avatar
    Join Date
    Apr 2006
    Location
    West Yorks
    Posts
    4,344
    What you describe above is exactly how su is supposed to work. If you want to inherit the environmental variables of the user you are switching to, then you need to use "su -" and not just "su" e.g. to switch to root and inherit the path and other environmental variables, you can do
    Code:
    su -
    To switch to user john and inherit their path and other environmental variables
    Code:
    su - john

  3. #3
    Just Joined! Shutdown's Avatar
    Join Date
    Aug 2009
    Location
    New York
    Posts
    70
    Quote Originally Posted by daark.child View Post
    What you describe above is exactly how su is supposed to work. If you want the environmental variables of the user you are switching to, then you need to use "su -" and not just "su".
    Ahhh thank you for the quick reply. That did it.

    So I guess "su -" will give you ROOT and it's environment, while just "su root" only gives you the privileges to perform root stuff..?

  4. #4
    Blackfooted Penguin daark.child's Avatar
    Join Date
    Apr 2006
    Location
    West Yorks
    Posts
    4,344
    Quote Originally Posted by Shutdown View Post
    Ahhh thank you for the quick reply. That did it.

    So I guess "su -" will give you ROOT and it's environment, while just "su root" only gives you the privileges to perform root stuff..?
    "su" just switches you to a new user (to root if you do not specify a user) but keeps your environmental settings. "su -" switches you to the new user and you also switch to their environmental settings such as their path, aliases etc.

  5. #5
    Just Joined! Shutdown's Avatar
    Join Date
    Aug 2009
    Location
    New York
    Posts
    70
    Is there any difference between $BASH and $SHELL? I get the same results. Is one deprecated but somehow is still supported for backward compatibility?


    [root@linux01 ~]# echo $BASH
    /bin/bash

    [root@linux01 ~]# echo $SHELL
    /bin/bash

  6. #6
    Linux Engineer Thrillhouse's Avatar
    Join Date
    Jun 2006
    Location
    Arlington, VA, USA
    Posts
    1,377
    I'm guessing that $BASH is just a short-circuited version of $SHELL (specific to bash obviously). $SHELL is more generic. You happen to be using bash so the two are the same but if you were to be using the korn, shell your $SHELL would be /usr/bin/ksh and you probably would not have a $BASH variable (at least I do not in my korn shell).

  7. #7
    Just Joined! Shutdown's Avatar
    Join Date
    Aug 2009
    Location
    New York
    Posts
    70
    Quote Originally Posted by Thrillhouse View Post
    I'm guessing that $BASH is just a short-circuited version of $SHELL (specific to bash obviously). $SHELL is more generic. You happen to be using bash so the two are the same but if you were to be using the korn, shell your $SHELL would be /usr/bin/ksh and you probably would not have a $BASH variable (at least I do not in my korn shell).

    ahh ok. So I confused myself by using bash already, that's why the results look the same.

    Is korn a better shell or is it just preference? Also are there a lot of different shell's out there?

    Or is Korn and Bash the only two widely used?

  8. #8
    Linux Engineer Thrillhouse's Avatar
    Join Date
    Jun 2006
    Location
    Arlington, VA, USA
    Posts
    1,377
    There are a bunch of different shells, of which bash is one. The Bourne again shell (bash) is a follow-on to the Bourne shell (sh). The korn shell is another. There's also the C shell or csh, and the Z shell zsh. The Wikipedia page on UNIX shells is a good place to start:

    Unix shell - Wikipedia, the free encyclopedia

    There's not too much of a difference between bash and ksh, so if you're a beginner, I would just stick with bash until you find a need to move to another. Most Linux systems default to the bash shell. Although not all UNIX systems do.

  9. #9
    Blackfooted Penguin daark.child's Avatar
    Join Date
    Apr 2006
    Location
    West Yorks
    Posts
    4,344
    There are many different shells out there. Most Linux distros default to bash, but you can install ksh, pdksh, csh, tcsh, zsh (which is my favourite), fish etc. Search for "linux shells" and "unix shells" and you should be able to find articles that discuss the various shells.

  10. #10
    Just Joined! Shutdown's Avatar
    Join Date
    Aug 2009
    Location
    New York
    Posts
    70
    Thanks guys, I get the jist of it now on shells.

    Once I become more of a power user of linux, I will probably start to find which shell is best for me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...