Su vs Sudo: Difference and Comparison

Linux has several commands and ways to gain root privileges. Each command and function works and invokes differently.

Key Takeaways

  1. The “su” command switches to the root user or another user account, while the “sudo” command temporarily elevates a user’s privileges to perform tasks as a superuser.
  2. “su” requires the target user’s password, while “sudo” requires the executing user’s password.
  3. “sudo” provides more granular control over user permissions, whereas “su” grants complete access to the target user account.

Su vs Sudo

su, short for switch user, is a command that allows a user to switch to another user account, the root account, by entering the target user’s password. Sudo, short for superuser do, is a command that allows a user to execute a command as another user by entering their own password.

Su vs Sudo

Su stands for substitute user. It is a traditional way to acquire root permission in Linux. It was released in 1971. The main syntax of the command is su[user_name] or su-[user_name].

While Sudo stands for substitute user do. It is used for gaining permission for administrative and executable tasks. The main syntax of the command is sudo[command].

Comparison Table

Parameters of comparisonSuSudo
TypeCommand Privilege authorization
Operating SystemUnix and Unix-like Unix-like
FunctionTo seek root permission through switching to superuser or root user To seek root permission through a single command
AuthorDennis Ritchie and Ken Thompson Robert Coggeshall and Cliff Spencer
DeveloperAT&T Bell LaboratoriesTodd C. Miller

What is Su?

The full form of Su is ‘substitute user’. It was initially a part of the Version 1 Unix. It was developed by Dennis Ritchie and Ken Thompson.

Also Read:  Squareup vs Godaddy: Difference and Comparison

The job of the su command is to execute commands and provide the privilege of another account of the user. Upon execution, the su command invokes a shell and does not change the present working directory or the environment of the user.

If the command is used without initially specifying the new user id, which would serve as the command line argument, the su command would use the superuser account of the system as the default setting.

Upon authentication, the operator would grant access to the account. It would even grant permission for the files and directories in the account.

What is Sudo?

Sudo is a type of program in the operating system of Unix-like. The full form of sudo is ‘substitute user do’. In the default setting, it allows superuser.

The job of the Sudo command is to allow users to run programs and provide security privileges for other users. The license is of ISC style. It is extensively used in the C language.

Sudo is also used for administrative tasks. Sudo authenticates by asking for the password of the user and not of the target user. After authentication, it permits access and invokes a requested command.

Sudo is a single command and runs with root privileges. Unlike su, it does not switch to a root user account or ask for the root user’s credentials like a password.

Main Differences Between Su and Sudo

  1. Su command users need to create separate root and user account passwords during installation, while Sudo command users only need to provide a single password.
  2. Su invokes the root shell and keeps it open during normal functioning, while Sudo runs fewer commands in roots and increases security.
References
  1. https://link.springer.com/chapter/10.1007/978-1-4842-5049-5_11
  2. https://link.springer.com/chapter/10.1007/978-3-030-78120-0_13
Also Read:  Passport vs Passport JWT: Difference and Comparison

Last Updated : 19 August, 2023

dot 1
One request?

I’ve put so much effort writing this blog post to provide value to you. It’ll be very helpful for me, if you consider sharing it on social media or with your friends/family. SHARING IS ♥️

22 thoughts on “Su vs Sudo: Difference and Comparison”

  1. The detailed comparison of the su and sudo commands in this article is highly informative. The overview effectively demonstrates the unique functions and use cases of each command.

    Reply
    • Absolutely! The detailed explanations of the su and sudo commands have highlighted their essential differences and use cases. It’s an excellent resource for users seeking clarity on these commands.

      Reply
    • I share your sentiment! The article provides an exceptional comparison of the su and sudo commands, offering valuable insights into their specific functionalities and historical background.

      Reply
  2. The comparison between the su and sudo commands presented in this article is incredibly detailed and informative. It effectively highlights the unique functions and differences of each command.

    Reply
    • I share your viewpoint! The detailed comparison and functionalities of the su and sudo commands are incredibly valuable. It’s an excellent resource for users seeking to enhance their understanding of these commands.

      Reply
  3. The comprehensive breakdown of the su and sudo commands in this article is incredibly helpful. The detailed information provides a clear understanding of their respective roles and functionalities.

    Reply
    • I completely agree! The in-depth comparisons and explanations of the su and sudo commands offer valuable insights into their distinct purposes and usage. It’s a commendable piece of information.

      Reply
  4. A very informative and well-structured overview of the su and sudo commands. The detailed comparison and functionalities provide a clear understanding of the purpose of each command.

    Reply
  5. A very detailed and useful comparison between the su and sudo commands. The insights provided regarding the historical background and functionality of each command are quite enlightening.

    Reply
    • Absolutely! The comprehensive overview of the su and sudo commands has provided valuable clarity regarding their respective roles and functionalities. A very informative piece indeed!

      Reply
    • I totally agree! The article effectively covers the fundamental differences and functions of the su and sudo commands. The comparison table is particularly helpful in understanding their contrasting features.

      Reply
  6. An excellent and informative guide to understanding the differences between the su and sudo commands. The historical context and detailed comparisons aid in providing a comprehensive understanding of their functionalities.

    Reply
    • Absolutely! The detailed explanations of the su and sudo commands in this article have been incredibly informative. It’s a great resource for users wanting to gain a better understanding of these commands.

      Reply
    • I completely agree! This article offers valuable insights into the distinct functionalities of the su and sudo commands. The comprehensive overview provides clarity on their roles and usage.

      Reply
  7. The detailed explanation and comparison of the su and sudo commands in this article are highly valuable for users seeking to understand the fundamental differences and use cases of each command.

    Reply
  8. This article provides a thorough understanding of the su and sudo commands, offering valuable insights into their individual functionalities and distinct features.

    Reply
    • Absolutely! The detailed explanations and comparison of the su and sudo commands have been quite enlightening. It’s an excellent resource for users seeking to learn more about these commands.

      Reply
  9. This article does a great job of explaining the essential differences between the su and sudo commands. The historical context and detailed comparisons effectively clarify their distinct purposes.

    Reply
    • Indeed! The detailed comparisons and explanations of the su and sudo commands are incredibly beneficial. It’s a very insightful piece with valuable information for users.

      Reply
    • I couldn’t agree more! This article is a very informative guide to understanding the differences between su and sudo commands. The comparison table and the detailed descriptions are incredibly helpful.

      Reply
  10. The information provided about the differences between the su and sudo commands is quite instructive and can help users to realize the functionalities of each command. Thank you!

    Reply
    • Indeed, I couldn’t agree more! This article is very informative about the principal differences between su and sudo commands and the functions of each of them. Thanks for sharing!

      Reply

Leave a Comment

Want to save this article for later? Click the heart in the bottom right corner to save to your own articles box!