Difference between revisions of "Useradd"
Jump to navigation
Jump to search
↑ https://linux.die.net/man/8/useradd
↑ http://man7.org/linux/man-pages/man8/useradd.8.html
↑ http://man7.org/linux/man-pages/man8/useradd.8.html
(11 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{lowercase}} | {{lowercase}} | ||
− | <code>useradd</code><ref>https://linux.die.net/man/8/useradd</ref> - create a new user or update default new user information | + | <code>useradd</code><ref>https://linux.die.net/man/8/useradd</ref> - create a new user or update default new user information ([https://linux.die.net/man/8/useradd man]) |
− | |||
− | [[useradd -m]] YOUR_USERNAME -s /bin/[[bash]] | + | [[useradd -m]] YOUR_USERNAME [[-s]] [[/bin/]][[bash]] |
-m, --create-home | -m, --create-home | ||
<code>useradd -m YOUR_USERNAME --[[uid]] #### --[[gid]] #### -s [[/bin/bash]] --create-home</code> | <code>useradd -m YOUR_USERNAME --[[uid]] #### --[[gid]] #### -s [[/bin/bash]] --create-home</code> | ||
+ | <code>useradd -m YOUR_USERNAME -[[g]] your-group -s [[/bin/bash]] --create-home</code> | ||
+ | [[-c]] | ||
== Add user using [[Ansible]] == | == Add user using [[Ansible]] == | ||
Line 69: | Line 70: | ||
* <code>[[CREATE ROLE]]</code> | * <code>[[CREATE ROLE]]</code> | ||
* <code>[[groupadd]]</code> | * <code>[[groupadd]]</code> | ||
+ | * [[aws iam create-user]] | ||
+ | * [[AWS]]: <code>[[aws iam create-role]]</code> | ||
+ | * <code>[[aws_iam_user]]</code> | ||
+ | * <code>[[Kubernetes services accounts]]: [[kind: ServiceAccount]]</code> | ||
+ | * <code>[[kubectl create clusterrolebinding]] ops-user-cluster-admin-binding --clusterrole=[[cluster-admin]] --user=ops-user</code> | ||
+ | * <code>[[USER]]</code> | ||
== Activities == | == Activities == |
Latest revision as of 13:46, 8 November 2024
useradd
[1] - create a new user or update default new user information (man)
useradd -m YOUR_USERNAME -s /bin/bash -m, --create-home
useradd -m YOUR_USERNAME --uid #### --gid #### -s /bin/bash --create-home
useradd -m YOUR_USERNAME -g your-group -s /bin/bash --create-home
-c
Contents
Add user using Ansible[edit]
- user: name: YOUR_USER_NAME shell: /bin/bash groups: sudo append: yes password_lock: yes
Add user using bash[edit]
Example creating a user in Ubuntu with bash shell, ~/.ssh directory and part of group sudo using useradd
[2] command:
#!/bin/bash USERNAME="Your_user_name" # Create user and add to sudo group useradd --create-home -s /bin/bash $USERNAME sudo usermod -aG sudo $USERNAME #Create ssh directory and lock password login mkdir /home/$USERNAME /home/$USERNAME/.ssh chown $USERNAME.$USERNAME /home/$USERNAME /home/$USERNAME/.ssh passwd -l $USERNAME
passwd -l $USERNAME
// for disabling password loginpasswd -u $USERNAME
// will unlock account if needed
After creating user you can copy ssh key using ssh-copy-id
and modifying sudo
for giving new user privileges.
useradd command[edit]
useradd
[3] command.
-m --create-home -M, --no-create-home -N, --no-user-group -s --shell
useradd -m YOUR_USERNAME -s /bin/bash
You can also consider activating passwordless sudo
for your accounts.
Related commands[edit]
jailkit
,ChrootDirectory
passwd
userdel
,usermod
adduser
(BusyBox)groups
,chgrp
- Cisco IOS:
username
- FreeIPA:
ipa user-add
- macOS:
sysadminctl -addUser USERNAME
dscl . -create /Users/USERNAME_HERE
~/.ssh/
- Cisco IOS: Associate a user with default higher privileges:
username
CREATE ROLE
groupadd
- aws iam create-user
- AWS:
aws iam create-role
aws_iam_user
Kubernetes services accounts: kind: ServiceAccount
kubectl create clusterrolebinding ops-user-cluster-admin-binding --clusterrole=cluster-admin --user=ops-user
USER
Activities[edit]
See also[edit]
- macOS:
sysadminctl
sudo
,id
,visudo
,useradd
,userdel
,usermod
,groups
,passwd
,chown
,chmod
,chgrp
,groupadd
,groupdel
, Passwordless sudo, passwd (package),sudo --help
groups
orid
commands to list groups of a user. sudousermod -a -G root USERNAME
useradd, adduser
(BusyBox),usermod, groupmod
,userdel
,groupadd
,dscl
,/Users/, groups, id
Advertising: