linux question

Discussion in 'OT Technology' started by D1G1T4L, Feb 4, 2004.

  1. D1G1T4L

    D1G1T4L Active Member

    Joined:
    May 4, 2001
    Messages:
    16,489
    Likes Received:
    0
    Location:
    Bay Area
    When i try some commands like ifconfig for example i get this
    -bash: ifconfig: command not found

    i am guessing i have to fix this in .bash_profile, the $PATH var ?

    also it happens when u just use "su" to switch to root account but when i use "su-" it executes fine

    whats the difference between su and su -
     
    Last edited: Feb 4, 2004
  2. s a x m a n

    s a x m a n New Member

    Joined:
    Nov 16, 2003
    Messages:
    880
    Likes Received:
    0
    su - loads the bash profile for root, as where su doesn't.

    ifconfig needs to be run as root, will not work otherwise
     
  3. Joe_Cool

    Joe_Cool Never trust a woman or a government. Moderator

    Joined:
    Jun 30, 2003
    Messages:
    299,382
    Likes Received:
    580
    More generally, su - [user] runs /etc/bashrc, /etc/profile, ~user/.bashrc when it logs you in (assuming you're using bash). It executes all the configuration files for your shell as if user had typed his username & password at the login prompt.

    su [user] only switches your UID to user's UID and gives you his privileges and access.

    If you just use su (not su -) you can execute your configuration files like this:
    # . /etc/bashrc && . ~/.bashrc

    Make sure there's a space after the first dot - that makes the current shell execute those script files.
     
  4. s a x m a n

    s a x m a n New Member

    Joined:
    Nov 16, 2003
    Messages:
    880
    Likes Received:
    0
    i think mine was more general .... (=
     
  5. Joe_Cool

    Joe_Cool Never trust a woman or a government. Moderator

    Joined:
    Jun 30, 2003
    Messages:
    299,382
    Likes Received:
    580
    when I said more general I mean that it works for any user, not just root. you can do su - noob and become user noob - if you're root or know noob's password.

    The other stuff was less general. :)
     

Share This Page