User accounts: Difference between revisions

From Han Wiki
Jump to navigation Jump to search
No edit summary
→‎Groups: add other sections
Line 4: Line 4:
== Add a new group ==
== Add a new group ==


<source lang="bash">
<syntaxhighlight lang="bash">
$ sudo addgroup webdev
$ sudo addgroup webdev
</source>
or
$ sudo groupadd webdev
</syntaxhighlight>


== Delete a group ==
== Delete a group ==


<source lang="bash">
<syntaxhighlight lang="bash">
$ sudo delgroup webdev
$ sudo delgroup webdev
</source>
or
$ sudo groupdel webdev
</syntaxhighlight>


== Add a user to a group ==
== Add a user to a group ==


<source lang="bash">
<syntaxhighlight lang="bash">
$ sudo adduser username groupname
$ sudo adduser username groupname
</source>
or
$ sudo useradd -a G groupname username
</syntaxhighlight>
 
== Change a user's primary group ==
 
<syntaxhighlight lang="bash">
$ sudo usermod -g groupname username
</syntaxhighlight>
 
== Check user's group assignments ==
 
<syntaxhighlight lang="bash">
$ id username
or
$ groups username
or
$ id -Gn username
</syntaxhighlight>


== Set a directory writable by a certain group ==
== Set a directory writable by a certain group ==

Revision as of 12:13, 17 August 2016

Groups

Add a new group

$ sudo addgroup webdev
or
$ sudo groupadd webdev

Delete a group

$ sudo delgroup webdev
or
$ sudo groupdel webdev

Add a user to a group

$ sudo adduser username groupname
or
$ sudo useradd -a G groupname username

Change a user's primary group

$ sudo usermod -g groupname username

Check user's group assignments

$ id username
or
$ groups username
or
$ id -Gn username

Set a directory writable by a certain group

Make /srv/www folder readable/writable/executable by dev group

$ sudo setfacl -d -m g:dev:rwx /srv/www

Add a user account

$ sudo useradd -d /home/jsmith -m jsmith -G webdev
$ sudo passwd jsmith

Delete a user account

Force removal and delete files

$ sudo userdel -fr username

or

$ sudo deluser -remove-home username

Lock or unlock a user account

$ sudo passwd -l username
$ sudo passwd -u username

Adding sudoers

A file can be added for groups of users or specific users to /etc/sudoers.d/ directory. This line would make someone a sudoer with no password requirement.

jsmith ALL=(ALL) NOPASSWD:ALL

If you want the user to type a password.

jsmith ALL=(ALL:ALL) ALL