What is the significance of $(logname)?Difference between logname and $LOGNAMEWhat is the significance of single and double quotes in environment variables?What is the difference between 'env' and 'printenv'?What is the use of “export” command?How to prevent the caller's shell from being used in sudoDifference between logname and $LOGNAMEMaster environment script based on $LOGNAME to run on any shell invocationWhat are the environment variables by default?What is the meaning of “_=”?What is the effect of a path separator at the beginning of an environment variable?What is the status of setting environment variables without ~/.bash_profile?
Why not demand President's/candidate's financial records instead of tax returns?
Link for download latest Edubuntu
How can I communicate my issues with a potential date's pushy behavior?
How do I call a 6-digit Australian phone number with a US-based mobile phone?
What is the safest way to leave my MacBook on 24/7 with macOS Mojave?
Are there any cons in using rounded corners for bar graphs?
Letting unbanned users comment
Doesn't the speed of light limit imply the same electron can be annihilated twice?
Does fossil fuels use since 1990 account for half of all the fossil fuels used in history?
In which case does the Security misconfiguration vulnerability apply to?
Chunk + Enumerate a list of digits
Identifying My Main Water Shutoff Valve / Setup
graphs in latex
Are employers legally allowed to pay employees in goods and services equal to or greater than the minimum wage?
Why aren't rockets built with truss structures inside their fuel & oxidizer tanks to increase structural strength?
If a person claims to know anything could it be disproven by saying 'prove that we are not in a simulation'?
What unique challenges/limitations will I face if I start a career as a pilot at 45 years old?
What is the hottest thing in the universe?
Transition to "Starvation Mode" in Survival Situations
Are there really no countries that protect Freedom of Speech as the United States does?
Are there any other rule mechanics that could grant Thieves' Cant?
Why command hierarchy, if the chain of command is standing next to each other?
How did Arecibo detect methane lakes on Titan, and image Saturn's rings?
Pokemon Go: Gym Badge Over-completed?
What is the significance of $(logname)?
Difference between logname and $LOGNAMEWhat is the significance of single and double quotes in environment variables?What is the difference between 'env' and 'printenv'?What is the use of “export” command?How to prevent the caller's shell from being used in sudoDifference between logname and $LOGNAMEMaster environment script based on $LOGNAME to run on any shell invocationWhat are the environment variables by default?What is the meaning of “_=”?What is the effect of a path separator at the beginning of an environment variable?What is the status of setting environment variables without ~/.bash_profile?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
sudo sh -c 'echo "$(logname) ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/$(logname)' & sudo chmod 440 /etc/sudoers.d/$(logname)
I use the above one-liner to allow the current user to execute sudo without a password, on remotely connected hosts.
But what exactly is $(logname)?
On a local machine, echo $(logname) returns nothing, while echo $LOGNAME does, so it's not the environmental variable, although I have never seen the value to be any different on remote machines.
Also, are there any other similar $(foo) variables (or whatever they are called)?
environment-variables
add a comment |
sudo sh -c 'echo "$(logname) ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/$(logname)' & sudo chmod 440 /etc/sudoers.d/$(logname)
I use the above one-liner to allow the current user to execute sudo without a password, on remotely connected hosts.
But what exactly is $(logname)?
On a local machine, echo $(logname) returns nothing, while echo $LOGNAME does, so it's not the environmental variable, although I have never seen the value to be any different on remote machines.
Also, are there any other similar $(foo) variables (or whatever they are called)?
environment-variables
2
It appears thatecho $(logname)is in fact different toecho $LOGNAMEon remote hosts whensu'd into another account.
– paradroid
Aug 2 at 14:10
This look strange to me, you need sudo right (at least with password prompt) to executesudoin first place.
– Archemar
Aug 2 at 14:51
Dupe unix.stackexchange.com/questions/268378/… . If command logname doesn't work on your 'local machine' it isn't POSIX-compliant.
– dave_thompson_085
Aug 3 at 2:15
add a comment |
sudo sh -c 'echo "$(logname) ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/$(logname)' & sudo chmod 440 /etc/sudoers.d/$(logname)
I use the above one-liner to allow the current user to execute sudo without a password, on remotely connected hosts.
But what exactly is $(logname)?
On a local machine, echo $(logname) returns nothing, while echo $LOGNAME does, so it's not the environmental variable, although I have never seen the value to be any different on remote machines.
Also, are there any other similar $(foo) variables (or whatever they are called)?
environment-variables
sudo sh -c 'echo "$(logname) ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/$(logname)' & sudo chmod 440 /etc/sudoers.d/$(logname)
I use the above one-liner to allow the current user to execute sudo without a password, on remotely connected hosts.
But what exactly is $(logname)?
On a local machine, echo $(logname) returns nothing, while echo $LOGNAME does, so it's not the environmental variable, although I have never seen the value to be any different on remote machines.
Also, are there any other similar $(foo) variables (or whatever they are called)?
environment-variables
environment-variables
edited Aug 2 at 14:03
paradroid
asked Aug 2 at 13:50
paradroidparadroid
4251 gold badge6 silver badges18 bronze badges
4251 gold badge6 silver badges18 bronze badges
2
It appears thatecho $(logname)is in fact different toecho $LOGNAMEon remote hosts whensu'd into another account.
– paradroid
Aug 2 at 14:10
This look strange to me, you need sudo right (at least with password prompt) to executesudoin first place.
– Archemar
Aug 2 at 14:51
Dupe unix.stackexchange.com/questions/268378/… . If command logname doesn't work on your 'local machine' it isn't POSIX-compliant.
– dave_thompson_085
Aug 3 at 2:15
add a comment |
2
It appears thatecho $(logname)is in fact different toecho $LOGNAMEon remote hosts whensu'd into another account.
– paradroid
Aug 2 at 14:10
This look strange to me, you need sudo right (at least with password prompt) to executesudoin first place.
– Archemar
Aug 2 at 14:51
Dupe unix.stackexchange.com/questions/268378/… . If command logname doesn't work on your 'local machine' it isn't POSIX-compliant.
– dave_thompson_085
Aug 3 at 2:15
2
2
It appears that
echo $(logname) is in fact different to echo $LOGNAME on remote hosts when su'd into another account.– paradroid
Aug 2 at 14:10
It appears that
echo $(logname) is in fact different to echo $LOGNAME on remote hosts when su'd into another account.– paradroid
Aug 2 at 14:10
This look strange to me, you need sudo right (at least with password prompt) to execute
sudo in first place.– Archemar
Aug 2 at 14:51
This look strange to me, you need sudo right (at least with password prompt) to execute
sudo in first place.– Archemar
Aug 2 at 14:51
Dupe unix.stackexchange.com/questions/268378/… . If command logname doesn't work on your 'local machine' it isn't POSIX-compliant.
– dave_thompson_085
Aug 3 at 2:15
Dupe unix.stackexchange.com/questions/268378/… . If command logname doesn't work on your 'local machine' it isn't POSIX-compliant.
– dave_thompson_085
Aug 3 at 2:15
add a comment |
1 Answer
1
active
oldest
votes
logname(1) is a command that will return the login name of the current user.$( ... ) is the syntax for command substitution which is saying "substitute the output of the command here"
So if your user is foo you are executing:
sudo sh -c 'echo "foo ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/foo' & sudo chmod 440 /etc/sudoers.d/foo
add a comment |
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',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f533573%2fwhat-is-the-significance-of-logname%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
logname(1) is a command that will return the login name of the current user.$( ... ) is the syntax for command substitution which is saying "substitute the output of the command here"
So if your user is foo you are executing:
sudo sh -c 'echo "foo ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/foo' & sudo chmod 440 /etc/sudoers.d/foo
add a comment |
logname(1) is a command that will return the login name of the current user.$( ... ) is the syntax for command substitution which is saying "substitute the output of the command here"
So if your user is foo you are executing:
sudo sh -c 'echo "foo ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/foo' & sudo chmod 440 /etc/sudoers.d/foo
add a comment |
logname(1) is a command that will return the login name of the current user.$( ... ) is the syntax for command substitution which is saying "substitute the output of the command here"
So if your user is foo you are executing:
sudo sh -c 'echo "foo ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/foo' & sudo chmod 440 /etc/sudoers.d/foo
logname(1) is a command that will return the login name of the current user.$( ... ) is the syntax for command substitution which is saying "substitute the output of the command here"
So if your user is foo you are executing:
sudo sh -c 'echo "foo ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/foo' & sudo chmod 440 /etc/sudoers.d/foo
answered Aug 2 at 13:55
Jesse_bJesse_b
18.6k3 gold badges46 silver badges86 bronze badges
18.6k3 gold badges46 silver badges86 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f533573%2fwhat-is-the-significance-of-logname%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
It appears that
echo $(logname)is in fact different toecho $LOGNAMEon remote hosts whensu'd into another account.– paradroid
Aug 2 at 14:10
This look strange to me, you need sudo right (at least with password prompt) to execute
sudoin first place.– Archemar
Aug 2 at 14:51
Dupe unix.stackexchange.com/questions/268378/… . If command logname doesn't work on your 'local machine' it isn't POSIX-compliant.
– dave_thompson_085
Aug 3 at 2:15