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

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

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. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  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.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

24 Responses

  1. Haley says:

    Is there a way to exclude a command for a sudo user?

  2. Albarki says:

    Can u clear Q2 please, cause it is not clear . Thanks.

  3. Victor says:

    I agree with Tomas,

    su means Substitute User. So we can use su to switch user temporarily. In this way we can switch to root user. The sudo one gives temporarily root privileges, using the normal user password.

    I really do not understand this article :(.

  4. Tomas says:

    What a misleading article name that is.

    You use “sudo” when you need to execute a command as a superuser. You use “su” when you want to switch to another user’s account, or, execute a command AS another user, not necessarily a superuser.

    Saying that “su forces you to share your root password to other users whereas sudo makes it possible to execute system commands without root password” shows you having no idea what the real purpose (and the difference) is.

    • old486whizz says:

      1. I read as far as the second mention of “editing the /usr/sbin/visudo file” .. The file you are editing is in fact /etc/sudoers. /usr/sbin/visudo is the binary you are running.

      2. As has been pointed out, su is mainly used to switch to another user’s shell. sudo is mainly there for scripts, but it also allows you to centralize configuration and as you describe, no additional password requirements.
      You can do with sudo exactly the same as you would with su ([sudo -u $newuser -i] for example is the same as [su – $newuser] – although you have to be weary of some environment variables).

      3. sudo may or may not be SUID (as SELinux becomes more popular, the settings are actually going in there rather than SUID).

      4. “Parameters of sudo” looks like it should actually be “Syntax of sudoers file” or “Syntax of sudo config”… Parameters are what you pass on the command line.

      5. adduser instead of useradd? You must really only know specific linux’s as useradd is the traditional Unix command (and adduser is actually a symbolic link to the correct useradd command… no idea why)

      6. It doesn’t look like you’ve stated you always need to use the full path name to the binary in the config file (dog will not do – it has to be /path/to/dog).

      7. “Linux System is much secured than any of its counterpart.” – I’m pretty sure several BSD fanatics will disagree with you there. BSD (kernel) is built with security more in mind – Linux (kernel) is built with more compromises and different ideals.

    • n0neXn0ne says:


      In his context, Technically he is correct.

      From su man page

      su – change user ID or become superuser

  5. Rodrigo Gonzalez says:

    One comment about the article, you dont need root password to use su

    su default is root but not only that

    if I want to change my user id to become user test I run

    su test

    and I need test user password not root password

    Best regards

    Rodrigo Gonzalez

  6. Manoj says:

    Dear Sir,

    I have a query. It’s not related to this post.

    How to assign hard quota to limited user in centos/Ubuntu ?

    Kindly let us know about this.

    Manoj Gupta

  7. Gurdip says:

    Plz provide video tutorial

  8. Quovadis says:

    If a newbie ask me what different between su and sudo, i simply answer that su require root password where sudo require your cyrrent password. :D

    • Avishek Kumar says:

      Dear Quovadis,
      we prepare our post after several hours of study, research, test before making it available to you. Our post is for Newbies as well as advanced users. Actually we write our contents from every possible user perspective.

      Keep connected to Tecmint for such detailed posts.

  9. Manoj says:

    Hello Sir,

    Thanks for this article, because i thought that both are same but this article clear me différence between both.



    • Avishek Kumar says:

      Dear Manoj,
      It was very pleasing to know our posts helped you.

      Keep connected to Tecmint for more such posts.
      Refer to your friends and colleagues.

Got something to say? Join the discussion.

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.