When can a user do `sudo su` but not `sudo su -`?
Clash 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
sudo su
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.
add a comment |Â
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
sudo su
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 ofsudo 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
add a comment |Â
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
sudo su
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
sudo su
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 ofsudo 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
add a comment |Â
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 ofsudo 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
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
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.
answered Dec 7 '15 at 16:57
Andrew
91557
91557
add a comment |Â
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
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.
answered Jul 10 at 14:33
telcoM
12.5k11436
12.5k11436
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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 ofsudo 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