Difference Between su and sudo and How to Configure sudo in Linux

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Use our Linode referral link if you plan to buy VPS (it starts at only $10/month).
  4. Support us via PayPal donate - Make a Donation
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Receive Your Free Complimentary eBook NOW! -

Download Free Linux eBooks

Advanced Bash-Scripting Guide
Linux Bible
A Newbie's Getting Started Guide to Linux
Introduction to Linux - A Hands on Guide

You may also like...

24 Responses

  1. Tachyon says:

    These comments are based on a multi user environment. In the case of shared computers of truly multi-user systems, sudo makes sense. However for single user systems and administrator use, su makes more sense for a variety of reasons including convenience and environment configuration.

    I do understand the confusion in this regard, especially with younger users, as Ubuntu started this confusion by misusing sudo to give it a more Windows like admin configuration model for individual admin tasks as it utterly lacks any unified administration interface where you’d give the root password once to enter and configure the system.

    So for example, as an administrator of my system, I keep a terminal shell open in which I’ve su’d to root and use that shell for all admin tasks.

    If I wanted to allow other users of the system to have access to network configuration or printer setup, I’d use sudo to allow access to those tools.

  2. Laxma Reddy says:

    Hi Ravi Saive,

    Good evening.

    I have a doubt in the below line.
    mark beta.database_server.com=(tom) ALL

    My understanding is ‘mark’ and ‘tom’ both are the sudo users, both users have same (ALL commands )access on beta.database_server.com machine.

    Is this correct? or any difference is there in between ‘mark’ and ‘tom’ users in terms of privileges on beta.database_server.com machine?

    Thanks in advance.

    Thanks

  3. Could you please explain more about Q2, i didn’t quite catch that. As per to the question, user tom which is supposed to execute system command as user other than root on the same database server.

    mark beta.database_server.com=(tom) ALL

    Mark — Sudo User
    beta.database_server.com — machine name
    tom — effective user
    ALL — Any command can be executed

    After login with Mark user, try executing commands it says permission denied. Would you please provide more clarification

  4. Roger Gardner says:

    How can I get sudo to use the root aliases in /etc/bashrc?

    • Ravi Saive says:

      @Roger,
      That’s not possible, either add aliases to sudo user .bash_profile file, or for global use add in /etc/profile file.

  5. Mushthaq says:

    Hi friends,

    I have two user accounts. let test1 and test2. How can I switch to test2 from test1 without prompting password.
    :$su test2

    Any idea, please contact me at mushthaq089@gmail.com

    • Ravi Saive says:

      @Mushthaq,
      That’s not possible, because both are different users with different home directories, you must enter password to login to user account..

      • kannan says:

        What if the password is not set for neither of the users? It still prompting for password and what we have to give?

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

Join Over 150K+ Linux Users
  1. 100,756
  2. 5,113
  3. 36,418

Enter your email to get latest Linux Howto's