How to manage /etc/passwd file

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











up vote
1
down vote

favorite
1












Let's say I want to keep the /etc/passwd file divided into system users like admin, wheel, root etc., and by actual users all at the end.



How do I do that? By creating subdirectories?







share|improve this question


















  • 1




    Do you mean /etc/passwd? What's wrong with using the standard tools? What sort of "managing" of this file would you want to do? Please edit your question to clarifiy what you are actually trying to achieve.
    – roaima
    Mar 23 at 23:33











  • hi roaima.... what i was trying to ask is how to keep the /etc/passwd file divided into system users like admin, wheel, root etc and by actual users all at the end. thank you - denny
    – Denny
    Mar 23 at 23:51











  • you can always (carefully) edit the file manually and move lines around. new users are appended to the bottom. how often are you adding system users and regular users? If nothing else, you can sort -n -t ':' -k3 /etc/passwd | less
    – ivanivan
    Mar 24 at 0:19















up vote
1
down vote

favorite
1












Let's say I want to keep the /etc/passwd file divided into system users like admin, wheel, root etc., and by actual users all at the end.



How do I do that? By creating subdirectories?







share|improve this question


















  • 1




    Do you mean /etc/passwd? What's wrong with using the standard tools? What sort of "managing" of this file would you want to do? Please edit your question to clarifiy what you are actually trying to achieve.
    – roaima
    Mar 23 at 23:33











  • hi roaima.... what i was trying to ask is how to keep the /etc/passwd file divided into system users like admin, wheel, root etc and by actual users all at the end. thank you - denny
    – Denny
    Mar 23 at 23:51











  • you can always (carefully) edit the file manually and move lines around. new users are appended to the bottom. how often are you adding system users and regular users? If nothing else, you can sort -n -t ':' -k3 /etc/passwd | less
    – ivanivan
    Mar 24 at 0:19













up vote
1
down vote

favorite
1









up vote
1
down vote

favorite
1






1





Let's say I want to keep the /etc/passwd file divided into system users like admin, wheel, root etc., and by actual users all at the end.



How do I do that? By creating subdirectories?







share|improve this question














Let's say I want to keep the /etc/passwd file divided into system users like admin, wheel, root etc., and by actual users all at the end.



How do I do that? By creating subdirectories?









share|improve this question













share|improve this question




share|improve this question








edited Mar 24 at 8:43









Kusalananda

102k13201317




102k13201317










asked Mar 23 at 23:29









Denny

4115




4115







  • 1




    Do you mean /etc/passwd? What's wrong with using the standard tools? What sort of "managing" of this file would you want to do? Please edit your question to clarifiy what you are actually trying to achieve.
    – roaima
    Mar 23 at 23:33











  • hi roaima.... what i was trying to ask is how to keep the /etc/passwd file divided into system users like admin, wheel, root etc and by actual users all at the end. thank you - denny
    – Denny
    Mar 23 at 23:51











  • you can always (carefully) edit the file manually and move lines around. new users are appended to the bottom. how often are you adding system users and regular users? If nothing else, you can sort -n -t ':' -k3 /etc/passwd | less
    – ivanivan
    Mar 24 at 0:19













  • 1




    Do you mean /etc/passwd? What's wrong with using the standard tools? What sort of "managing" of this file would you want to do? Please edit your question to clarifiy what you are actually trying to achieve.
    – roaima
    Mar 23 at 23:33











  • hi roaima.... what i was trying to ask is how to keep the /etc/passwd file divided into system users like admin, wheel, root etc and by actual users all at the end. thank you - denny
    – Denny
    Mar 23 at 23:51











  • you can always (carefully) edit the file manually and move lines around. new users are appended to the bottom. how often are you adding system users and regular users? If nothing else, you can sort -n -t ':' -k3 /etc/passwd | less
    – ivanivan
    Mar 24 at 0:19








1




1




Do you mean /etc/passwd? What's wrong with using the standard tools? What sort of "managing" of this file would you want to do? Please edit your question to clarifiy what you are actually trying to achieve.
– roaima
Mar 23 at 23:33





Do you mean /etc/passwd? What's wrong with using the standard tools? What sort of "managing" of this file would you want to do? Please edit your question to clarifiy what you are actually trying to achieve.
– roaima
Mar 23 at 23:33













hi roaima.... what i was trying to ask is how to keep the /etc/passwd file divided into system users like admin, wheel, root etc and by actual users all at the end. thank you - denny
– Denny
Mar 23 at 23:51





hi roaima.... what i was trying to ask is how to keep the /etc/passwd file divided into system users like admin, wheel, root etc and by actual users all at the end. thank you - denny
– Denny
Mar 23 at 23:51













you can always (carefully) edit the file manually and move lines around. new users are appended to the bottom. how often are you adding system users and regular users? If nothing else, you can sort -n -t ':' -k3 /etc/passwd | less
– ivanivan
Mar 24 at 0:19





you can always (carefully) edit the file manually and move lines around. new users are appended to the bottom. how often are you adding system users and regular users? If nothing else, you can sort -n -t ':' -k3 /etc/passwd | less
– ivanivan
Mar 24 at 0:19











2 Answers
2






active

oldest

votes

















up vote
4
down vote













You can edit the file (carefully!) with vipw. (Don't use an editor directly on the file as vipw will sanity-check the result before updating /etc/passwd.) If you want a different editor, such as nano, you can request that like this:



vipw # Uses default editor
EDITOR=nano vipw # Uses nano as the preferred editor


You can sort the file by ascending order of UID. This will separate system accounts that typically have lower numbers from user accounts that typically have higher numbers:



sort -n -t: -k3,4 /etc/passwd >/etc/passwd.old &&
cp -fp /etc/passwd.old /etc/passwd


(That can be run all on one line if you prefer.) An unchanged copy of the password file is left in /etc/passwd.old.






share|improve this answer





























    up vote
    3
    down vote













    UID ranges define system vs. user accounts.



    That is unless you are using a global LDAP server or equivalent to manage users & groups which would still conform to the reference but merely extends the ranges.



    Typically system accounts or those with a UID less than 100 are system reserved. Applications that create a local entry to assist with privilege escalation problems in the event of a design flaw are 100 - 499. 500 and above are for users.



    Typically manual editing of the local passwd database is frowned upon and should be managed with tools such as useradd, userdel, passwd, usermod etc.



    If you are simply looking for a way to audit accounts and want them sorted on output the following bit will work.



    sort -d: -k2 /etc/passwd






    share|improve this answer




















    • For persistent sorting, there is pwck -s and grpck -s.
      – telcoM
      Mar 26 at 21:13










    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%2f433176%2fhow-to-manage-etc-passwd-file%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
    4
    down vote













    You can edit the file (carefully!) with vipw. (Don't use an editor directly on the file as vipw will sanity-check the result before updating /etc/passwd.) If you want a different editor, such as nano, you can request that like this:



    vipw # Uses default editor
    EDITOR=nano vipw # Uses nano as the preferred editor


    You can sort the file by ascending order of UID. This will separate system accounts that typically have lower numbers from user accounts that typically have higher numbers:



    sort -n -t: -k3,4 /etc/passwd >/etc/passwd.old &&
    cp -fp /etc/passwd.old /etc/passwd


    (That can be run all on one line if you prefer.) An unchanged copy of the password file is left in /etc/passwd.old.






    share|improve this answer


























      up vote
      4
      down vote













      You can edit the file (carefully!) with vipw. (Don't use an editor directly on the file as vipw will sanity-check the result before updating /etc/passwd.) If you want a different editor, such as nano, you can request that like this:



      vipw # Uses default editor
      EDITOR=nano vipw # Uses nano as the preferred editor


      You can sort the file by ascending order of UID. This will separate system accounts that typically have lower numbers from user accounts that typically have higher numbers:



      sort -n -t: -k3,4 /etc/passwd >/etc/passwd.old &&
      cp -fp /etc/passwd.old /etc/passwd


      (That can be run all on one line if you prefer.) An unchanged copy of the password file is left in /etc/passwd.old.






      share|improve this answer
























        up vote
        4
        down vote










        up vote
        4
        down vote









        You can edit the file (carefully!) with vipw. (Don't use an editor directly on the file as vipw will sanity-check the result before updating /etc/passwd.) If you want a different editor, such as nano, you can request that like this:



        vipw # Uses default editor
        EDITOR=nano vipw # Uses nano as the preferred editor


        You can sort the file by ascending order of UID. This will separate system accounts that typically have lower numbers from user accounts that typically have higher numbers:



        sort -n -t: -k3,4 /etc/passwd >/etc/passwd.old &&
        cp -fp /etc/passwd.old /etc/passwd


        (That can be run all on one line if you prefer.) An unchanged copy of the password file is left in /etc/passwd.old.






        share|improve this answer














        You can edit the file (carefully!) with vipw. (Don't use an editor directly on the file as vipw will sanity-check the result before updating /etc/passwd.) If you want a different editor, such as nano, you can request that like this:



        vipw # Uses default editor
        EDITOR=nano vipw # Uses nano as the preferred editor


        You can sort the file by ascending order of UID. This will separate system accounts that typically have lower numbers from user accounts that typically have higher numbers:



        sort -n -t: -k3,4 /etc/passwd >/etc/passwd.old &&
        cp -fp /etc/passwd.old /etc/passwd


        (That can be run all on one line if you prefer.) An unchanged copy of the password file is left in /etc/passwd.old.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 24 at 9:36









        Kusalananda

        102k13201317




        102k13201317










        answered Mar 24 at 8:19









        roaima

        39.5k545107




        39.5k545107






















            up vote
            3
            down vote













            UID ranges define system vs. user accounts.



            That is unless you are using a global LDAP server or equivalent to manage users & groups which would still conform to the reference but merely extends the ranges.



            Typically system accounts or those with a UID less than 100 are system reserved. Applications that create a local entry to assist with privilege escalation problems in the event of a design flaw are 100 - 499. 500 and above are for users.



            Typically manual editing of the local passwd database is frowned upon and should be managed with tools such as useradd, userdel, passwd, usermod etc.



            If you are simply looking for a way to audit accounts and want them sorted on output the following bit will work.



            sort -d: -k2 /etc/passwd






            share|improve this answer




















            • For persistent sorting, there is pwck -s and grpck -s.
              – telcoM
              Mar 26 at 21:13














            up vote
            3
            down vote













            UID ranges define system vs. user accounts.



            That is unless you are using a global LDAP server or equivalent to manage users & groups which would still conform to the reference but merely extends the ranges.



            Typically system accounts or those with a UID less than 100 are system reserved. Applications that create a local entry to assist with privilege escalation problems in the event of a design flaw are 100 - 499. 500 and above are for users.



            Typically manual editing of the local passwd database is frowned upon and should be managed with tools such as useradd, userdel, passwd, usermod etc.



            If you are simply looking for a way to audit accounts and want them sorted on output the following bit will work.



            sort -d: -k2 /etc/passwd






            share|improve this answer




















            • For persistent sorting, there is pwck -s and grpck -s.
              – telcoM
              Mar 26 at 21:13












            up vote
            3
            down vote










            up vote
            3
            down vote









            UID ranges define system vs. user accounts.



            That is unless you are using a global LDAP server or equivalent to manage users & groups which would still conform to the reference but merely extends the ranges.



            Typically system accounts or those with a UID less than 100 are system reserved. Applications that create a local entry to assist with privilege escalation problems in the event of a design flaw are 100 - 499. 500 and above are for users.



            Typically manual editing of the local passwd database is frowned upon and should be managed with tools such as useradd, userdel, passwd, usermod etc.



            If you are simply looking for a way to audit accounts and want them sorted on output the following bit will work.



            sort -d: -k2 /etc/passwd






            share|improve this answer












            UID ranges define system vs. user accounts.



            That is unless you are using a global LDAP server or equivalent to manage users & groups which would still conform to the reference but merely extends the ranges.



            Typically system accounts or those with a UID less than 100 are system reserved. Applications that create a local entry to assist with privilege escalation problems in the event of a design flaw are 100 - 499. 500 and above are for users.



            Typically manual editing of the local passwd database is frowned upon and should be managed with tools such as useradd, userdel, passwd, usermod etc.



            If you are simply looking for a way to audit accounts and want them sorted on output the following bit will work.



            sort -d: -k2 /etc/passwd







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 24 at 9:33









            jas-

            71038




            71038











            • For persistent sorting, there is pwck -s and grpck -s.
              – telcoM
              Mar 26 at 21:13
















            • For persistent sorting, there is pwck -s and grpck -s.
              – telcoM
              Mar 26 at 21:13















            For persistent sorting, there is pwck -s and grpck -s.
            – telcoM
            Mar 26 at 21:13




            For persistent sorting, there is pwck -s and grpck -s.
            – telcoM
            Mar 26 at 21:13












             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f433176%2fhow-to-manage-etc-passwd-file%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?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?