Difference between revisions of "Usermod"

From wikieduonline
Jump to navigation Jump to search
 
(21 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
{{lowercase}}
 +
<code>[[usermod]]</code> command included in <code>[[Passwd (package)|passwd]]</code> package: https://linux.die.net/man/8/usermod
  
 +
Add an additional secondary group:
 +
* <code>sudo usermod -aG sudo YOUR_USERNAME</code>
 +
* <code>usermod -a -G YOUR_GROUP YOUR_USERNAME</code>
  
sudo usermod -aG sudo <username>
+
Change primary group for user:
 
+
  [[usermod -g]] yournewprimarygroupname yourusername
  usermod -a -G YOUR_GROUP YOUR_USERNAME
 
  
 
  usermod -s /usr/sbin/nologin myuser
 
  usermod -s /usr/sbin/nologin myuser
 
  [[ssh]] and [[scp]] will fail
 
  [[ssh]] and [[scp]] will fail
  
 +
* <code>[[groups]]</code>
 +
* <code>[[groups]] USERNAME</code>
  
[[groups]] USERNAME
+
You may need to start a new login shell after adding user: <code>su - USERNAME</code>
  
 +
<code>sudo [[usermod -l]] newusername oldusername</code> change user name
  
 
== Related commands ==
 
== Related commands ==
Line 16: Line 23:
 
* <code>[[groups]]</code>
 
* <code>[[groups]]</code>
 
* [[Passwordless sudo]]
 
* [[Passwordless sudo]]
 +
* <code>[[visudo]]</code>, <code>[[sudoers]]</code>
 +
* [[macOS]]: <code>sudo [[dseditgroup]] -o edit -a $username_to_add -t user admin</code>
  
 
== See also ==
 
== See also ==
 +
* {{usermod}}
 
* {{Linux Commands privileges}}
 
* {{Linux Commands privileges}}
 +
 +
[[Category:Linux]]

Latest revision as of 13:41, 28 December 2023

usermod command included in passwd package: https://linux.die.net/man/8/usermod

Add an additional secondary group:

  • sudo usermod -aG sudo YOUR_USERNAME
  • usermod -a -G YOUR_GROUP YOUR_USERNAME

Change primary group for user:

usermod -g yournewprimarygroupname yourusername
usermod -s /usr/sbin/nologin myuser
ssh and scp will fail

You may need to start a new login shell after adding user: su - USERNAME

sudo usermod -l newusername oldusername change user name

Related commands[edit]

See also[edit]

Advertising: