Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

askthedev.com Logo askthedev.com Logo
Sign InSign Up

askthedev.com

Search
Ask A Question

Mobile menu

Close
Ask A Question
  • Ubuntu
  • Python
  • JavaScript
  • Linux
  • Git
  • Windows
  • HTML
  • SQL
  • AWS
  • Docker
  • Kubernetes
Home/ Questions/Q 8290
Next
In Process

askthedev.com Latest Questions

Asked: September 25, 20242024-09-25T19:02:17+05:30 2024-09-25T19:02:17+05:30In: Linux

What distinguishes the commands su and sudo su in a Linux environment?

anonymous user

I’ve been diving into some Linux stuff recently, and I keep bumping into this distinction between the commands “su” and “sudo su.” At first, I thought they were basically the same thing, but the more I read, the more confused I get. It seems like there’s a real difference, but I’m not entirely sure what that is.

So, here’s the deal: when you run “su,” it feels like you’re switching users, and I get that. But then there’s “sudo su,” and I can’t quite wrap my head around why I should use one over the other. I mean, is it just about who has permissions? Or is there more to it? And what’s the deal with the security implications? I’ve heard that one is considered safer than the other, but why?

I also read somewhere that “sudo” allows for fine-grained access control. Does that mean you don’t just have to give a blanket permission to some user? Can you specify what they can and can’t do? How does that fit into the “su” command? It’s a bit overwhelming to think about all the different configurations and settings.

Plus, it feels like every online forum has people who swear by one method or the other. Some folks say using “sudo su” is better for admin tasks while others insist you should stick with standard “su” for straightforward user switching. It makes me wonder if there’s a best practice out there or if it’s really just down to personal preference.

I’m really interested in hearing from anyone who might have some insights or real-world experiences with these commands. When did you find yourself using one over the other, and what were the outcomes? Any tips or straightforward scenarios where using either one makes a significant difference? I’m all ears, and I could really use some clarity to avoid future Linux headaches!

  • 0
  • 0
  • 2 2 Answers
  • 0 Followers
  • 0
Share
  • Facebook

    Leave an answer
    Cancel reply

    You must login to add an answer.

    Continue with Google
    or use

    Forgot Password?

    Need An Account, Sign Up Here
    Continue with Google

    2 Answers

    • Voted
    • Oldest
    • Recent
    1. anonymous user
      2024-09-25T19:02:18+05:30Added an answer on September 25, 2024 at 7:02 pm



      Understanding su vs sudo su

      What’s the Difference Between su and sudo su?

      It’s awesome that you’re digging into Linux! When it comes to su and sudo su, they do have their differences, and it can be a bit confusing at first.

      su (Substitute User)

      When you type su alone, you’re switching to the root user (or another specified user) after entering the user’s password. So, if you don’t have the root password, you can’t use it. It’s like getting a VIP pass, but only if you have that special password.

      sudo su

      Now, with sudo su, you’re actually using sudo (superuser do) to gain root access. Here, you enter your own password (the one you use to log in) instead of the root password. This is kind of like getting a VIP pass without needing the secret password; you just need to be on the guest list (i.e., you need permission to use sudo).

      Permissions and Security

      Here’s where it gets interesting! sudo allows for fine-grained access control. That means you can set up rules detailing what users can or cannot do. So, instead of handing over complete control to someone, you can give them just enough power to do their job. This is way safer than su, which gives full access if you have the password.

      Which One to Use?

      In terms of best practices, many suggest using sudo as much as possible and reserving su for situations where you really need to switch users entirely. The “less is more” idea comes into play here. Using sudo keeps things secure and manageable because it tracks what commands are run by whom, which is really handy for system logs.

      Real-world Scenarios

      For example, if you just need to install a package or run a specific command as root, just do:

      sudo apt install package-name

      But, if you’re logged in as a normal user and need to sit in the root seat for a while, you might do:

      sudo su

      This way, you can run multiple commands without needing to prefix each with sudo, but keep in mind it’s best to exit root mode when done!

      Conclusion

      Both commands have their place, but generally, sudo is recommended for better security and tracking. It’s okay if you prefer one over the other, but getting used to sudo is a solid way to handle permissions in Linux. Play around with both, and see what feels comfortable for you!

      Don’t hesitate to jump into forums for help, and always remember: it’s all part of learning! Happy Linux-ing!


        • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    2. anonymous user
      2024-09-25T19:02:19+05:30Added an answer on September 25, 2024 at 7:02 pm


      The distinction between the commands “su” and “sudo su” primarily revolves around user permissions and security practices in a Linux environment. The “su” command, which stands for “substitute user,” allows a user to switch to another user account, often the superuser (root), using that user’s password. This command gives full access to the new user’s session, meaning if you switch to root using “su,” you inherit all the privileges and responsibilities associated with that account without any restrictions. On the other hand, “sudo su” is a combination of “sudo,” which stands for “superuser do,” and “su.” The “sudo” command allows a permitted user to execute specific commands as the superuser or another user, as dictated by the configurations set in the /etc/sudoers file. When using “sudo su”, the user only needs to provide their own password (not the target user’s password), and this creates an additional layer of security by logging the command and its usage, thus creating an audit trail. This means that “sudo” can provide fine-grained access control, allowing specific users to execute certain commands without giving them full access to the superuser account, making it a safer and more manageable option in many cases.

      In terms of best practices, many Linux distributions recommend using “sudo” over “su” due to its enhanced security and finer control over permissions. While some might argue that using “su” is more straightforward for quick user switches, in a multi-user or production environment, using “sudo” is usually preferable. This is particularly true in scenarios where you want to limit user capabilities to specific administrative functions while still allowing them to perform necessary tasks without giving away complete control of the system. The choice between “su” and “sudo su” often comes down to personal preference, but it’s crucial to consider the context in which you’re operating. If security and accountability are priorities, opting for “sudo” is widely considered best practice by system administrators.


        • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp

    Related Questions

    • What could be the reason that using tcpdump with the -i any option fails to capture unicast traffic on a Linux bridge interface, such as br0?
    • How can I configure SELinux or AppArmor to permit only certain specified applications to execute on my system?
    • I'm trying to set up Virtual Routing and Forwarding (VRF) on my Linux system, but I'm not receiving any ping responses from the configured interfaces. I've followed the necessary steps ...
    • What distinguishes the /etc/profile file from the .bashrc file in a Linux environment?
    • What distinguishes the commands cat and tee in Linux?

    Sidebar

    Related Questions

    • What could be the reason that using tcpdump with the -i any option fails to capture unicast traffic on a Linux bridge interface, such as ...

    • How can I configure SELinux or AppArmor to permit only certain specified applications to execute on my system?

    • I'm trying to set up Virtual Routing and Forwarding (VRF) on my Linux system, but I'm not receiving any ping responses from the configured interfaces. ...

    • What distinguishes the /etc/profile file from the .bashrc file in a Linux environment?

    • What distinguishes the commands cat and tee in Linux?

    • What are some interesting games that can be played directly from the command line in a Linux environment?

    • How can I retrieve the command-line arguments of a running process using the ps command in Linux?

    • What are the files in a Linux system that start with a dot, and what is their purpose?

    • Is there a method to obtain Linux applications from different computers?

    • I'm encountering difficulties when trying to access a remote Linux server via SSH using ngrok. Despite following the setup instructions, I cannot establish a connection. ...

    Recent Answers

    1. anonymous user on How do games using Havok manage rollback netcode without corrupting internal state during save/load operations?
    2. anonymous user on How do games using Havok manage rollback netcode without corrupting internal state during save/load operations?
    3. anonymous user on How can I efficiently determine line of sight between points in various 3D grid geometries without surface intersection?
    4. anonymous user on How can I efficiently determine line of sight between points in various 3D grid geometries without surface intersection?
    5. anonymous user on How can I update the server about my hotbar changes in a FabricMC mod?
    • Home
    • Learn Something
    • Ask a Question
    • Answer Unanswered Questions
    • Privacy Policy
    • Terms & Conditions

    © askthedev ❤️ All Rights Reserved

    Explore

    • Ubuntu
    • Python
    • JavaScript
    • Linux
    • Git
    • Windows
    • HTML
    • SQL
    • AWS
    • Docker
    • Kubernetes

    Insert/edit link

    Enter the destination URL

    Or link to existing content

      No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.