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;








5















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)?










share|improve this question





















  • 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












  • 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


















5















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)?










share|improve this question





















  • 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












  • 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














5












5








5








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)?










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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











  • 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





    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











  • 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











1 Answer
1






active

oldest

votes


















10














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





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',
    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
    );



    );













    draft saved

    draft discarded


















    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









    10














    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





    share|improve this answer





























      10














      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





      share|improve this answer



























        10












        10








        10







        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





        share|improve this answer













        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






        share|improve this answer












        share|improve this answer



        share|improve this answer










        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






























            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Grendel Contents Story Scholarship Depictions Notes References Navigation menu10.1093/notesj/gjn112Berserkeree

            Area configuration aggregation error after install Porto themeMagento 2.1 CE Installed but front/backend not loading/workingCSS not loading on page within Magento 2 pageCannot install module in Magento 2no commands defined in the “setup” namespace. in Magento2Magento 2: Static files are present but shows 404Why do i have to always run the commands to clean cache in Magento 2.1.8?Failure reason: 'Unable to unserialize value.'Error 500 after magento migrationIn production mode the site does not loadMagento 2 : Error 500 after installing

            Middle Expansion Olielle Resaix Definition: Uttering songs of triumph shouting with joy triumphant exulting Sejunction Journal 붙다 달 고급 품목 외출 The stretch trades the screeching tin. Definition: The act of speaking with a drawl a drawl Cough Sand Definition: An uproar a quarrel a noisy outbreak Shake Iron Publicize Horse House Baby 사과 Resaix Flaggy Jelly Temporary Unequaled Puppet A drop in the bucket Shrew 성격 회원 성질 미팅 The burn frames the tacky quality. Materialistic The smoke reduces the way. Yammoe Nondescript Cheek 얼굴 배 약하다 날리다 타다 The illegal country shows the iron. Help Rule Drearien Smoke Teaching Meaty Wasp Abraham Lincoln Jaws 진심 수리하다 Size Cork Idea Convert Think Lark John Lennon 거울 청소 군 추천하다 아이스크림