When can a user do `sudo su` but not `sudo su -`?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












The following happened to me:



$ sudo su - superman

Sorry, user clarkkent is not allowed to execute '/bin/su - superman' as root in krypton101.


However the following worked fine:



$ sudo su superman


When is it useful to allow a user to do sudo su but not sudo su -? How is this setting set / unset? I read this page but it didn't help.



More details:



  • I am not the administrator

  • I don't have access to /etc/sudoers

  • the distribution is Centos 7









share|improve this question
















bumped to the homepage by Community♦ 8 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • Is this your personal machine or does someone else administer it? Can you see the contents of /etc/sudoers? If so, edit your question and add the output of sudo grep -w su /etc/sudoers. Also edit and add your distribution.
    – terdon♦
    Dec 2 '15 at 14:01







  • 1




    Relevant: Is there ever a good reason to run sudo su?
    – terdon♦
    Dec 2 '15 at 14:02






  • 1




    sudo -l will be helpful, it will show what commands you're allowed to execute even if you can't read /etc/sudoers and /etc/sudoers.d.
    – Ulrich Schwarz
    Dec 2 '15 at 14:04














up vote
2
down vote

favorite












The following happened to me:



$ sudo su - superman

Sorry, user clarkkent is not allowed to execute '/bin/su - superman' as root in krypton101.


However the following worked fine:



$ sudo su superman


When is it useful to allow a user to do sudo su but not sudo su -? How is this setting set / unset? I read this page but it didn't help.



More details:



  • I am not the administrator

  • I don't have access to /etc/sudoers

  • the distribution is Centos 7









share|improve this question
















bumped to the homepage by Community♦ 8 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • Is this your personal machine or does someone else administer it? Can you see the contents of /etc/sudoers? If so, edit your question and add the output of sudo grep -w su /etc/sudoers. Also edit and add your distribution.
    – terdon♦
    Dec 2 '15 at 14:01







  • 1




    Relevant: Is there ever a good reason to run sudo su?
    – terdon♦
    Dec 2 '15 at 14:02






  • 1




    sudo -l will be helpful, it will show what commands you're allowed to execute even if you can't read /etc/sudoers and /etc/sudoers.d.
    – Ulrich Schwarz
    Dec 2 '15 at 14:04












up vote
2
down vote

favorite









up vote
2
down vote

favorite











The following happened to me:



$ sudo su - superman

Sorry, user clarkkent is not allowed to execute '/bin/su - superman' as root in krypton101.


However the following worked fine:



$ sudo su superman


When is it useful to allow a user to do sudo su but not sudo su -? How is this setting set / unset? I read this page but it didn't help.



More details:



  • I am not the administrator

  • I don't have access to /etc/sudoers

  • the distribution is Centos 7









share|improve this question















The following happened to me:



$ sudo su - superman

Sorry, user clarkkent is not allowed to execute '/bin/su - superman' as root in krypton101.


However the following worked fine:



$ sudo su superman


When is it useful to allow a user to do sudo su but not sudo su -? How is this setting set / unset? I read this page but it didn't help.



More details:



  • I am not the administrator

  • I don't have access to /etc/sudoers

  • the distribution is Centos 7






sudo su






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 20 '17 at 10:18









Community♦

1




1










asked Dec 2 '15 at 13:49









usual me

1113




1113





bumped to the homepage by Community♦ 8 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community♦ 8 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.













  • Is this your personal machine or does someone else administer it? Can you see the contents of /etc/sudoers? If so, edit your question and add the output of sudo grep -w su /etc/sudoers. Also edit and add your distribution.
    – terdon♦
    Dec 2 '15 at 14:01







  • 1




    Relevant: Is there ever a good reason to run sudo su?
    – terdon♦
    Dec 2 '15 at 14:02






  • 1




    sudo -l will be helpful, it will show what commands you're allowed to execute even if you can't read /etc/sudoers and /etc/sudoers.d.
    – Ulrich Schwarz
    Dec 2 '15 at 14:04
















  • Is this your personal machine or does someone else administer it? Can you see the contents of /etc/sudoers? If so, edit your question and add the output of sudo grep -w su /etc/sudoers. Also edit and add your distribution.
    – terdon♦
    Dec 2 '15 at 14:01







  • 1




    Relevant: Is there ever a good reason to run sudo su?
    – terdon♦
    Dec 2 '15 at 14:02






  • 1




    sudo -l will be helpful, it will show what commands you're allowed to execute even if you can't read /etc/sudoers and /etc/sudoers.d.
    – Ulrich Schwarz
    Dec 2 '15 at 14:04















Is this your personal machine or does someone else administer it? Can you see the contents of /etc/sudoers? If so, edit your question and add the output of sudo grep -w su /etc/sudoers. Also edit and add your distribution.
– terdon♦
Dec 2 '15 at 14:01





Is this your personal machine or does someone else administer it? Can you see the contents of /etc/sudoers? If so, edit your question and add the output of sudo grep -w su /etc/sudoers. Also edit and add your distribution.
– terdon♦
Dec 2 '15 at 14:01





1




1




Relevant: Is there ever a good reason to run sudo su?
– terdon♦
Dec 2 '15 at 14:02




Relevant: Is there ever a good reason to run sudo su?
– terdon♦
Dec 2 '15 at 14:02




1




1




sudo -l will be helpful, it will show what commands you're allowed to execute even if you can't read /etc/sudoers and /etc/sudoers.d.
– Ulrich Schwarz
Dec 2 '15 at 14:04




sudo -l will be helpful, it will show what commands you're allowed to execute even if you can't read /etc/sudoers and /etc/sudoers.d.
– Ulrich Schwarz
Dec 2 '15 at 14:04










2 Answers
2






active

oldest

votes

















up vote
0
down vote













To answer the question: When is it useful to allow a user to do sudo su but not sudo su -?



The hyphen after su but before the username instructs su to allow the current user to inherit the environment of username. As long as clarkkent's environment has the necessary environment variables set to be able to run as superman, it is not necessary to run sudo su - superman.



A plausible 'reason' NOT to allow sudo su - superman may be that the system administrator believed sudo su - superman created a security risk. This is because sudo su -, without specifying a username, instructs the system to log you in as root user, which is likely something the system administrator is trying to avoid. I do not actually know for certain adding the hyphen creates this risk, or not, but I guess when it comes to security, it's better safe than sorry.



How is this setting set / unset?



The configuration is defined in the /etc/sudoers file.






share|improve this answer



























    up vote
    0
    down vote













    When specifying commands allowed via sudo, there are basically two easy options:



    • allow a specific command with any parameters, or

    • allow a specific command with an exactly specified set of parameters only.

    As a result, allowing both sudo su - superman and sudo su superman requires two entries in the sudoers file. It looks like your administrator has only provided you with one of them.



    The sudoers file syntax does not really let the administrator specify a specific command with wildcard- or regexp-limited options, because those specifications would be an all too easy to abuse. As Andrew said, better safe than sorry is the approach here.



    However, note that sudo su superman requires sudo to allow the original user to run su superman as root. Effectively, there will be two identity transitions instead of just one: first from original user to root by sudo and then from root to superman by su. The specification would look like this in the sudoers file:



    original_user ALL=(root) su superman


    On the other hand, the sudoers syntax has a much easier way to allow the user to run any commands as a specific user, if the user is not too fixated to the use of the su command.



    If the sudoers specification is written like this:



    original_user ALL=(superman) ALL


    then the user can use sudo -u superman -s to achieve a close (but possibly not exact) equivalent of sudo su superman and sudo -u superman -i to achieve an exact equivalent of sudo su - superman.



    Why people don't use this, but instead insist on using sudo su - constructs? Because the -i option did not exist in older versions of sudo!



    It only appeared sometime after year 2000, so there's plenty of old literature that still recommends the now-obsolete sudo su - construction. And of course, old Unix users and administrators may have that in muscle memory, so they'll use it without thinking.






    share|improve this answer




















      Your Answer







      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "106"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      convertImagesToLinks: false,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f246864%2fwhen-can-a-user-do-sudo-su-but-not-sudo-su%23new-answer', 'question_page');

      );

      Post as a guest






























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      0
      down vote













      To answer the question: When is it useful to allow a user to do sudo su but not sudo su -?



      The hyphen after su but before the username instructs su to allow the current user to inherit the environment of username. As long as clarkkent's environment has the necessary environment variables set to be able to run as superman, it is not necessary to run sudo su - superman.



      A plausible 'reason' NOT to allow sudo su - superman may be that the system administrator believed sudo su - superman created a security risk. This is because sudo su -, without specifying a username, instructs the system to log you in as root user, which is likely something the system administrator is trying to avoid. I do not actually know for certain adding the hyphen creates this risk, or not, but I guess when it comes to security, it's better safe than sorry.



      How is this setting set / unset?



      The configuration is defined in the /etc/sudoers file.






      share|improve this answer
























        up vote
        0
        down vote













        To answer the question: When is it useful to allow a user to do sudo su but not sudo su -?



        The hyphen after su but before the username instructs su to allow the current user to inherit the environment of username. As long as clarkkent's environment has the necessary environment variables set to be able to run as superman, it is not necessary to run sudo su - superman.



        A plausible 'reason' NOT to allow sudo su - superman may be that the system administrator believed sudo su - superman created a security risk. This is because sudo su -, without specifying a username, instructs the system to log you in as root user, which is likely something the system administrator is trying to avoid. I do not actually know for certain adding the hyphen creates this risk, or not, but I guess when it comes to security, it's better safe than sorry.



        How is this setting set / unset?



        The configuration is defined in the /etc/sudoers file.






        share|improve this answer






















          up vote
          0
          down vote










          up vote
          0
          down vote









          To answer the question: When is it useful to allow a user to do sudo su but not sudo su -?



          The hyphen after su but before the username instructs su to allow the current user to inherit the environment of username. As long as clarkkent's environment has the necessary environment variables set to be able to run as superman, it is not necessary to run sudo su - superman.



          A plausible 'reason' NOT to allow sudo su - superman may be that the system administrator believed sudo su - superman created a security risk. This is because sudo su -, without specifying a username, instructs the system to log you in as root user, which is likely something the system administrator is trying to avoid. I do not actually know for certain adding the hyphen creates this risk, or not, but I guess when it comes to security, it's better safe than sorry.



          How is this setting set / unset?



          The configuration is defined in the /etc/sudoers file.






          share|improve this answer












          To answer the question: When is it useful to allow a user to do sudo su but not sudo su -?



          The hyphen after su but before the username instructs su to allow the current user to inherit the environment of username. As long as clarkkent's environment has the necessary environment variables set to be able to run as superman, it is not necessary to run sudo su - superman.



          A plausible 'reason' NOT to allow sudo su - superman may be that the system administrator believed sudo su - superman created a security risk. This is because sudo su -, without specifying a username, instructs the system to log you in as root user, which is likely something the system administrator is trying to avoid. I do not actually know for certain adding the hyphen creates this risk, or not, but I guess when it comes to security, it's better safe than sorry.



          How is this setting set / unset?



          The configuration is defined in the /etc/sudoers file.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 7 '15 at 16:57









          Andrew

          91557




          91557






















              up vote
              0
              down vote













              When specifying commands allowed via sudo, there are basically two easy options:



              • allow a specific command with any parameters, or

              • allow a specific command with an exactly specified set of parameters only.

              As a result, allowing both sudo su - superman and sudo su superman requires two entries in the sudoers file. It looks like your administrator has only provided you with one of them.



              The sudoers file syntax does not really let the administrator specify a specific command with wildcard- or regexp-limited options, because those specifications would be an all too easy to abuse. As Andrew said, better safe than sorry is the approach here.



              However, note that sudo su superman requires sudo to allow the original user to run su superman as root. Effectively, there will be two identity transitions instead of just one: first from original user to root by sudo and then from root to superman by su. The specification would look like this in the sudoers file:



              original_user ALL=(root) su superman


              On the other hand, the sudoers syntax has a much easier way to allow the user to run any commands as a specific user, if the user is not too fixated to the use of the su command.



              If the sudoers specification is written like this:



              original_user ALL=(superman) ALL


              then the user can use sudo -u superman -s to achieve a close (but possibly not exact) equivalent of sudo su superman and sudo -u superman -i to achieve an exact equivalent of sudo su - superman.



              Why people don't use this, but instead insist on using sudo su - constructs? Because the -i option did not exist in older versions of sudo!



              It only appeared sometime after year 2000, so there's plenty of old literature that still recommends the now-obsolete sudo su - construction. And of course, old Unix users and administrators may have that in muscle memory, so they'll use it without thinking.






              share|improve this answer
























                up vote
                0
                down vote













                When specifying commands allowed via sudo, there are basically two easy options:



                • allow a specific command with any parameters, or

                • allow a specific command with an exactly specified set of parameters only.

                As a result, allowing both sudo su - superman and sudo su superman requires two entries in the sudoers file. It looks like your administrator has only provided you with one of them.



                The sudoers file syntax does not really let the administrator specify a specific command with wildcard- or regexp-limited options, because those specifications would be an all too easy to abuse. As Andrew said, better safe than sorry is the approach here.



                However, note that sudo su superman requires sudo to allow the original user to run su superman as root. Effectively, there will be two identity transitions instead of just one: first from original user to root by sudo and then from root to superman by su. The specification would look like this in the sudoers file:



                original_user ALL=(root) su superman


                On the other hand, the sudoers syntax has a much easier way to allow the user to run any commands as a specific user, if the user is not too fixated to the use of the su command.



                If the sudoers specification is written like this:



                original_user ALL=(superman) ALL


                then the user can use sudo -u superman -s to achieve a close (but possibly not exact) equivalent of sudo su superman and sudo -u superman -i to achieve an exact equivalent of sudo su - superman.



                Why people don't use this, but instead insist on using sudo su - constructs? Because the -i option did not exist in older versions of sudo!



                It only appeared sometime after year 2000, so there's plenty of old literature that still recommends the now-obsolete sudo su - construction. And of course, old Unix users and administrators may have that in muscle memory, so they'll use it without thinking.






                share|improve this answer






















                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  When specifying commands allowed via sudo, there are basically two easy options:



                  • allow a specific command with any parameters, or

                  • allow a specific command with an exactly specified set of parameters only.

                  As a result, allowing both sudo su - superman and sudo su superman requires two entries in the sudoers file. It looks like your administrator has only provided you with one of them.



                  The sudoers file syntax does not really let the administrator specify a specific command with wildcard- or regexp-limited options, because those specifications would be an all too easy to abuse. As Andrew said, better safe than sorry is the approach here.



                  However, note that sudo su superman requires sudo to allow the original user to run su superman as root. Effectively, there will be two identity transitions instead of just one: first from original user to root by sudo and then from root to superman by su. The specification would look like this in the sudoers file:



                  original_user ALL=(root) su superman


                  On the other hand, the sudoers syntax has a much easier way to allow the user to run any commands as a specific user, if the user is not too fixated to the use of the su command.



                  If the sudoers specification is written like this:



                  original_user ALL=(superman) ALL


                  then the user can use sudo -u superman -s to achieve a close (but possibly not exact) equivalent of sudo su superman and sudo -u superman -i to achieve an exact equivalent of sudo su - superman.



                  Why people don't use this, but instead insist on using sudo su - constructs? Because the -i option did not exist in older versions of sudo!



                  It only appeared sometime after year 2000, so there's plenty of old literature that still recommends the now-obsolete sudo su - construction. And of course, old Unix users and administrators may have that in muscle memory, so they'll use it without thinking.






                  share|improve this answer












                  When specifying commands allowed via sudo, there are basically two easy options:



                  • allow a specific command with any parameters, or

                  • allow a specific command with an exactly specified set of parameters only.

                  As a result, allowing both sudo su - superman and sudo su superman requires two entries in the sudoers file. It looks like your administrator has only provided you with one of them.



                  The sudoers file syntax does not really let the administrator specify a specific command with wildcard- or regexp-limited options, because those specifications would be an all too easy to abuse. As Andrew said, better safe than sorry is the approach here.



                  However, note that sudo su superman requires sudo to allow the original user to run su superman as root. Effectively, there will be two identity transitions instead of just one: first from original user to root by sudo and then from root to superman by su. The specification would look like this in the sudoers file:



                  original_user ALL=(root) su superman


                  On the other hand, the sudoers syntax has a much easier way to allow the user to run any commands as a specific user, if the user is not too fixated to the use of the su command.



                  If the sudoers specification is written like this:



                  original_user ALL=(superman) ALL


                  then the user can use sudo -u superman -s to achieve a close (but possibly not exact) equivalent of sudo su superman and sudo -u superman -i to achieve an exact equivalent of sudo su - superman.



                  Why people don't use this, but instead insist on using sudo su - constructs? Because the -i option did not exist in older versions of sudo!



                  It only appeared sometime after year 2000, so there's plenty of old literature that still recommends the now-obsolete sudo su - construction. And of course, old Unix users and administrators may have that in muscle memory, so they'll use it without thinking.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jul 10 at 14:33









                  telcoM

                  12.5k11436




                  12.5k11436



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f246864%2fwhen-can-a-user-do-sudo-su-but-not-sudo-su%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Popular posts from this blog

                      How to check contact read email or not when send email to Individual?

                      Bahrain

                      Postfix configuration issue with fips on centos 7; mailgun relay