sed to change userid in /etc/passwd to zero

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











up vote
0
down vote

favorite












I am trying to change user monitor uid in /etc/passwd , but below gives me an error:



sed -s /etc/passwd <<-"EOF"
/^(monitor:[^:]*:)[0-9]*:[0-9]*:/s//10:0:/
w
q
EOF









share|improve this question

















  • 7




    ... This sounds like a tremendously bad idea if you accidentally succeed. What are you actually trying to accomplish?
    – Shadur
    Oct 10 '17 at 14:11






  • 3




    Use usermod -u. That's what it is there for
    – Raman Sailopal
    Oct 10 '17 at 14:13






  • 6




    You're confusing sed with ed
    – Stéphane Chazelas
    Oct 10 '17 at 14:15






  • 4




    Why do you "need" to change userid to 0? I bet if you explained the problem you are really trying to solve, somebody would come up with a better idea of how to solve it.
    – NickD
    Oct 10 '17 at 14:19






  • 2




    How have you added the user to the admin group? With groupmod?
    – Raman Sailopal
    Oct 10 '17 at 14:43














up vote
0
down vote

favorite












I am trying to change user monitor uid in /etc/passwd , but below gives me an error:



sed -s /etc/passwd <<-"EOF"
/^(monitor:[^:]*:)[0-9]*:[0-9]*:/s//10:0:/
w
q
EOF









share|improve this question

















  • 7




    ... This sounds like a tremendously bad idea if you accidentally succeed. What are you actually trying to accomplish?
    – Shadur
    Oct 10 '17 at 14:11






  • 3




    Use usermod -u. That's what it is there for
    – Raman Sailopal
    Oct 10 '17 at 14:13






  • 6




    You're confusing sed with ed
    – Stéphane Chazelas
    Oct 10 '17 at 14:15






  • 4




    Why do you "need" to change userid to 0? I bet if you explained the problem you are really trying to solve, somebody would come up with a better idea of how to solve it.
    – NickD
    Oct 10 '17 at 14:19






  • 2




    How have you added the user to the admin group? With groupmod?
    – Raman Sailopal
    Oct 10 '17 at 14:43












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am trying to change user monitor uid in /etc/passwd , but below gives me an error:



sed -s /etc/passwd <<-"EOF"
/^(monitor:[^:]*:)[0-9]*:[0-9]*:/s//10:0:/
w
q
EOF









share|improve this question













I am trying to change user monitor uid in /etc/passwd , but below gives me an error:



sed -s /etc/passwd <<-"EOF"
/^(monitor:[^:]*:)[0-9]*:[0-9]*:/s//10:0:/
w
q
EOF






sed passwd uid






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Oct 10 '17 at 14:07









irom

186110




186110







  • 7




    ... This sounds like a tremendously bad idea if you accidentally succeed. What are you actually trying to accomplish?
    – Shadur
    Oct 10 '17 at 14:11






  • 3




    Use usermod -u. That's what it is there for
    – Raman Sailopal
    Oct 10 '17 at 14:13






  • 6




    You're confusing sed with ed
    – Stéphane Chazelas
    Oct 10 '17 at 14:15






  • 4




    Why do you "need" to change userid to 0? I bet if you explained the problem you are really trying to solve, somebody would come up with a better idea of how to solve it.
    – NickD
    Oct 10 '17 at 14:19






  • 2




    How have you added the user to the admin group? With groupmod?
    – Raman Sailopal
    Oct 10 '17 at 14:43












  • 7




    ... This sounds like a tremendously bad idea if you accidentally succeed. What are you actually trying to accomplish?
    – Shadur
    Oct 10 '17 at 14:11






  • 3




    Use usermod -u. That's what it is there for
    – Raman Sailopal
    Oct 10 '17 at 14:13






  • 6




    You're confusing sed with ed
    – Stéphane Chazelas
    Oct 10 '17 at 14:15






  • 4




    Why do you "need" to change userid to 0? I bet if you explained the problem you are really trying to solve, somebody would come up with a better idea of how to solve it.
    – NickD
    Oct 10 '17 at 14:19






  • 2




    How have you added the user to the admin group? With groupmod?
    – Raman Sailopal
    Oct 10 '17 at 14:43







7




7




... This sounds like a tremendously bad idea if you accidentally succeed. What are you actually trying to accomplish?
– Shadur
Oct 10 '17 at 14:11




... This sounds like a tremendously bad idea if you accidentally succeed. What are you actually trying to accomplish?
– Shadur
Oct 10 '17 at 14:11




3




3




Use usermod -u. That's what it is there for
– Raman Sailopal
Oct 10 '17 at 14:13




Use usermod -u. That's what it is there for
– Raman Sailopal
Oct 10 '17 at 14:13




6




6




You're confusing sed with ed
– Stéphane Chazelas
Oct 10 '17 at 14:15




You're confusing sed with ed
– Stéphane Chazelas
Oct 10 '17 at 14:15




4




4




Why do you "need" to change userid to 0? I bet if you explained the problem you are really trying to solve, somebody would come up with a better idea of how to solve it.
– NickD
Oct 10 '17 at 14:19




Why do you "need" to change userid to 0? I bet if you explained the problem you are really trying to solve, somebody would come up with a better idea of how to solve it.
– NickD
Oct 10 '17 at 14:19




2




2




How have you added the user to the admin group? With groupmod?
– Raman Sailopal
Oct 10 '17 at 14:43




How have you added the user to the admin group? With groupmod?
– Raman Sailopal
Oct 10 '17 at 14:43










1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










If for some reason usermod -u can not be used:



sed -i -e 's/^(monitor:[^:]):[0-9]*:[0-9]*:/1:0:0:/' /etc/passwd


Please note it is /1:0 not /10: as this would be parameter 10.



But having monitor to have uid 0 might not be a good idea at all.






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%2f397236%2fsed-to-change-userid-in-etc-passwd-to-zero%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    accepted










    If for some reason usermod -u can not be used:



    sed -i -e 's/^(monitor:[^:]):[0-9]*:[0-9]*:/1:0:0:/' /etc/passwd


    Please note it is /1:0 not /10: as this would be parameter 10.



    But having monitor to have uid 0 might not be a good idea at all.






    share|improve this answer
























      up vote
      1
      down vote



      accepted










      If for some reason usermod -u can not be used:



      sed -i -e 's/^(monitor:[^:]):[0-9]*:[0-9]*:/1:0:0:/' /etc/passwd


      Please note it is /1:0 not /10: as this would be parameter 10.



      But having monitor to have uid 0 might not be a good idea at all.






      share|improve this answer






















        up vote
        1
        down vote



        accepted







        up vote
        1
        down vote



        accepted






        If for some reason usermod -u can not be used:



        sed -i -e 's/^(monitor:[^:]):[0-9]*:[0-9]*:/1:0:0:/' /etc/passwd


        Please note it is /1:0 not /10: as this would be parameter 10.



        But having monitor to have uid 0 might not be a good idea at all.






        share|improve this answer












        If for some reason usermod -u can not be used:



        sed -i -e 's/^(monitor:[^:]):[0-9]*:[0-9]*:/1:0:0:/' /etc/passwd


        Please note it is /1:0 not /10: as this would be parameter 10.



        But having monitor to have uid 0 might not be a good idea at all.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Oct 10 '17 at 15:53









        hschou

        1,66349




        1,66349



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f397236%2fsed-to-change-userid-in-etc-passwd-to-zero%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?

            Christian Cage

            How to properly install USB display driver for Fresco Logic FL2000DX on Ubuntu?