• VMware

    Learn about VMware virtualization for its products like vsphere ESX and ESXi, vCenter Server, VMware View, VMware P2V and many more

  • Linux

    Step by step configuration tutorials for many of the Linux services like DNS, DHCP, FTP, Samba4 etc including many tips and tricks in Red Hat Linux.

  • Database

    Learn installation and configuration of databases like Oracle, My SQL, Postgresql, etc including many other related tutorials in Linux.

  • What is the difference between "su" and "su -" ?

    If we check the man page for su
    su - run a shell with substitute user and group IDs

    which means that if you use
    # su -
    you are switching user to the root user and asking the system to change all the environment variables applicable to root and take me to the root's home directory

    Using su - is same as logging into a fresh session on a terminal

    For example
    [deepak@server ~]$ pwd

    [deepak@server ~]$ echo $PATH

    [deepak@server ~]$ sudo su -
    [root@server ~]# pwd

    [root@server deepak]# echo $PATH

    But when you type only su without a dash(-) in that case the session is switched to root(if any username is not mentioned along with su command) without applying any of the environment variable of the root user.

    Also the new user stays in the same directory as he was before using su
    [deepak@server ~]$ echo $PATH

    [deepak@server ~]$ pwd

    [deepak@server ~]$ sudo su
    [root@server deepak]# pwd

    [root@server deepak]# echo $PATH

    I hope the article was useful.

    Deepak Prasad

    is a techie and an author who is still trying to survive in this IT generation with very little knowledge he has on Linux/Unix, VMware, SAN Storage, Automation, networking etc

    You can follow him on Facebook or Google+

    Do you also have something to share here?
    Join GoLinuxHub Team as an Author, Click here for more information
    What is the difference between "su" and "su -" ? What is the difference between "su" and "su -" ? Reviewed by Deepak Prasad on Thursday, January 30, 2014 Rating: 5

    No comments:

    Powered by Blogger.