Skip to content

Instantly share code, notes, and snippets.

@hmcclungiii
Last active January 5, 2020 19:32
Show Gist options
  • Select an option

  • Save hmcclungiii/ec44b2d975045691f0c6ef12ec7490bf to your computer and use it in GitHub Desktop.

Select an option

Save hmcclungiii/ec44b2d975045691f0c6ef12ec7490bf to your computer and use it in GitHub Desktop.

Revisions

  1. hmcclungiii revised this gist Jan 5, 2020. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions Linux-Terminal-Users-CRUD.md
    Original file line number Diff line number Diff line change
    @@ -21,6 +21,7 @@ addgroup

    ## Add a user
    * Omitting the groupname argument will cause a new group to be created with the same name as the new user.

    adduser `username` `groupname`

    ## Delete a user
  2. hmcclungiii revised this gist Jan 5, 2020. No changes.
  3. hmcclungiii revised this gist Jan 5, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Linux-Terminal-Users-CRUD.md
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@
    * Group info is stored at /etc/group

    ## Find all users that login through the terminal.
    sudo awk -F':' '$2 ~ "\\\$" {print $1}' /etc/shadow
    `sudo awk -F':' '$2 ~ "\\$" {print $1}' /etc/shadow`

    ## Get the groups a user belongs to.
    groups `username`
  4. hmcclungiii revised this gist Jan 5, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Linux-Terminal-Users-CRUD.md
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@
    * Group info is stored at /etc/group

    ## Find all users that login through the terminal.
    sudo awk -F':' '$2 ~ "\\$" {print $1}' /etc/shadow
    sudo awk -F':' '$2 ~ "\\\$" {print $1}' /etc/shadow

    ## Get the groups a user belongs to.
    groups `username`
  5. hmcclungiii revised this gist Jan 5, 2020. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion Linux-Terminal-Users-CRUD.md
    Original file line number Diff line number Diff line change
    @@ -45,8 +45,11 @@ edquota

    ## Regarding Sudo
    To grant sudo privileges to an existing user,
    `usermod -aG sudo _username_`
    `usermod -aG sudo username`

    ## Miscellaneous
    To switch users without having to logout and back in,
    `su - username`

    ## For more information:
    * https://www.computerhope.com/unix/adduser.htm
  6. hmcclungiii revised this gist Jan 5, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Linux-Terminal-Users-CRUD.md
    Original file line number Diff line number Diff line change
    @@ -45,7 +45,7 @@ edquota

    ## Regarding Sudo
    To grant sudo privileges to an existing user,
    `usermod -aG sudo ***username***`
    `usermod -aG sudo _username_`


    ## For more information:
  7. hmcclungiii revised this gist Jan 5, 2020. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions Linux-Terminal-Users-CRUD.md
    Original file line number Diff line number Diff line change
    @@ -43,6 +43,11 @@ chage
    ## Set a disk usage quota
    edquota

    ## Regarding Sudo
    To grant sudo privileges to an existing user,
    `usermod -aG sudo ***username***`


    ## For more information:
    * https://www.computerhope.com/unix/adduser.htm
    * https://linux.die.net/man/8/adduser
  8. hmcclungiii revised this gist Jan 5, 2020. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions Linux-Terminal-Users-CRUD.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    ## Important Files and Paths
    * /etc/login.defs is the configuration file for login parameters, containing some defaults that are used for the commands below.
    * /etc/adduser.conf contains the default configuration and settings for creating new users with adduser
    * The default files for new users is stored in /etc/skel, though this can be changed in /etc/adduser.conf
  9. hmcclungiii revised this gist Jan 5, 2020. 1 changed file with 12 additions and 12 deletions.
    24 changes: 12 additions & 12 deletions Linux-Terminal-Users-CRUD.md
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,9 @@
    ### /etc/login.defs is the configuration file for login parameters, containing some defaults that are used for the commands below.
    ### /etc/adduser.conf contains the default configuration and settings for creating new users with adduser
    ### The default files for new users is stored in /etc/skel, though this can be changed in /etc/adduser.conf
    ### The user database is stored at /etc/passwd
    ### User passwords are stored in /etc/shadow
    ### Group info is stored at /etc/group
    * /etc/login.defs is the configuration file for login parameters, containing some defaults that are used for the commands below.
    * /etc/adduser.conf contains the default configuration and settings for creating new users with adduser
    * The default files for new users is stored in /etc/skel, though this can be changed in /etc/adduser.conf
    * The user database is stored at /etc/passwd
    * User passwords are stored in /etc/shadow
    * Group info is stored at /etc/group

    ## Find all users that login through the terminal.
    sudo awk -F':' '$2 ~ "\\$" {print $1}' /etc/shadow
    @@ -19,7 +19,7 @@ id `uid`
    addgroup

    ## Add a user
    ### Omitting the groupname argument will cause a new group to be created with the same name as the new user.
    * Omitting the groupname argument will cause a new group to be created with the same name as the new user.
    adduser `username` `groupname`

    ## Delete a user
    @@ -32,7 +32,7 @@ passwd
    gpasswd

    ## Modify a user
    ### Where adduser only allows the user to be added to one group, usermod allows a user to be added to multiple groups.
    * Where adduser only allows the user to be added to one group, usermod allows a user to be added to multiple groups.
    usermod
    chfn

    @@ -43,8 +43,8 @@ chage
    edquota

    ## For more information:
    https://www.computerhope.com/unix/adduser.htm
    https://linux.die.net/man/8/adduser
    http://linuxadministrative.blogspot.com/2014/05/adduser-command-examples.html
    https://www.linuxtechi.com/linux-commands-to-manage-local-accounts/
    * https://www.computerhope.com/unix/adduser.htm
    * https://linux.die.net/man/8/adduser
    * http://linuxadministrative.blogspot.com/2014/05/adduser-command-examples.html
    * https://www.linuxtechi.com/linux-commands-to-manage-local-accounts/

  10. hmcclungiii created this gist Jan 5, 2020.
    50 changes: 50 additions & 0 deletions Linux-Terminal-Users-CRUD.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,50 @@
    ### /etc/login.defs is the configuration file for login parameters, containing some defaults that are used for the commands below.
    ### /etc/adduser.conf contains the default configuration and settings for creating new users with adduser
    ### The default files for new users is stored in /etc/skel, though this can be changed in /etc/adduser.conf
    ### The user database is stored at /etc/passwd
    ### User passwords are stored in /etc/shadow
    ### Group info is stored at /etc/group

    ## Find all users that login through the terminal.
    sudo awk -F':' '$2 ~ "\\$" {print $1}' /etc/shadow

    ## Get the groups a user belongs to.
    groups `username`

    ## Get the GIDs a user belongs to.
    id `username`
    id `uid`

    ## Add a group
    addgroup

    ## Add a user
    ### Omitting the groupname argument will cause a new group to be created with the same name as the new user.
    adduser `username` `groupname`

    ## Delete a user
    deluser

    ## Change a users password
    passwd

    ## Change group passwords
    gpasswd

    ## Modify a user
    ### Where adduser only allows the user to be added to one group, usermod allows a user to be added to multiple groups.
    usermod
    chfn

    ## Give password an expiration date
    chage

    ## Set a disk usage quota
    edquota

    ## For more information:
    https://www.computerhope.com/unix/adduser.htm
    https://linux.die.net/man/8/adduser
    http://linuxadministrative.blogspot.com/2014/05/adduser-command-examples.html
    https://www.linuxtechi.com/linux-commands-to-manage-local-accounts/