0% found this document useful (0 votes)
30 views2 pages

Citguy - Nix Users and Groups PDF

This document provides a cheat sheet summarizing common Linux commands for managing users and groups. It lists options for commands like passwd, useradd, usermod, groupadd and others that allow adding, modifying, locking and unlocking users and groups and setting attributes like home directories, user IDs, group memberships and passwords.

Uploaded by

Chester Connolly
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views2 pages

Citguy - Nix Users and Groups PDF

This document provides a cheat sheet summarizing common Linux commands for managing users and groups. It lists options for commands like passwd, useradd, usermod, groupadd and others that allow adding, modifying, locking and unlocking users and groups and setting attributes like home directories, user IDs, group memberships and passwords.

Uploaded by

Chester Connolly
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

*nix users and groups Cheat Sheet

by Ryan Johnson (CITguy) via cheatography.com/138/cs/132/

passwd [options] [LOGIN]

gpasswd [option] GROUP

useradd [options] LOGIN (cont)

-a, --all : This option can be used only with -S

-a, --add USER : Add the user to the named

-l, --no-log-init : Do not add the user to the

and shows the status for all users.

group.

lastlog and faillog databases.

-d, --delete : Delete a users password (make it

-d, --delete USER : Remove the user from the

-m, --create-home : Create the user's home

empty).

named group.

directory if it doesn't exist.

-e, --expire : Immediately expire an account's

-r, --remove-password : Remove the

-M : Don't create home directory.

password.

password from the named group.

-N, --no-user-group : Do not create a group

-i, --inactive INACTIVE : This option is used to

-R, --restrict : Restrict the access to the

with the same name as the user.

disable an account after the password has been

named group.

expired for a number of days. After an account

-o, --non-unique : Allow the creation of a user

-A, --administrators USER,... : Set the list of

account with a duplicate UID. Only valid along

administrative users.

with -u option

-M, --members USER,... : Set the list of group

-p, --password PASSWORD : The encrypted

members.

password. NOT Recommended!

has had an expired password for INACTIVE


days, the user may no longer sign on to the
account.
-k, --keep-tokens : Indicate password change
should be performed only for expired
authentication tokens (passwords).

-r, --system : Create system account


useradd [options] LOGIN

-s, --shell SHELL : The name of the user's

-b, --base-dir BASE_DIR : Default system

login shell.

account. This does not disable the account. The

base directory if -d is not specified.

-u, --uid UID : The numerical value of the users

user may still be able to login using another

-d, --home HOME_DIR : Use HOME_DIR as

ID. Must be unique unless -o option used

authentication token (e.g. a SSH key).

the value for the user's login directory.

-U, --user-group : Create group with the

-n, --mindays MIN_DAYS : Set the minimum

-e, --expiredate EXPIRE_DATE : Date on

same name as the user

number of days between password changes to

which the user account will be disabled.

MIN_DAYS. A value of zero indicates that the

(YYYY-MM-DD)

-Z, --selinux-user SEUSER : The SELinux

user may change their password at any time.

-f, --inactive INACTIVE : Number of days after

-S, --status : Display account status

a password expires until the account is

information. (login,locked/no/usable

disabled. (0 disables account on expiration. -1

password,date of last password change,min

disables the feature.)

age, max age, warning period, inactivity period)

-g, --gid GROUP : The group name or number

-u, --unlock : Unlock the password of the

of the users initial login group. The group name

named account.

must exist.

-w, --warndays WARN_DAYS : Number of

-G, --groups GROUP1[,...] : List of

days warning prior to a required password

supplementary groups for the user. Subject to

change.

same restrictions as -g.

-x, --maxdays MAX_DAYS : Set the maximum

-k, --skel SKEL_DIR : The skeleton directory

number of days a password remains valid. After

to be copied in the users home directory, upon

MAX_DAYS, the password will need to be

creation. Only valid if -m option specified

changed.

-K, --key KEY=VALUE : Overrides

-l, --lock : Lock the password of the named

user for the users login.


groupmod [options] GROUP
-g, --gid GID : The group ID will be changed to
GID.
-n, --new-name NEW_GROUP : Group name
will be changed from GROUP to
NEW_GROUP.
-o, --non-unique : When used with -g, allows
setting the group GID to a non-unique value.
-p, --password PASSWORD : The encrypted
password. NOT Recommended!

/etc/login.defs defaults. Multiple -K options can


be specified.

By Ryan Johnson (CITguy)

Published 19th December, 2011.

Sponsored by Readability-Score.com

cheatography.com/citguy/

Last updated 20th December, 2011.

Measure your website readability!

Page 1 of 2.

https://readability-score.com

*nix users and groups Cheat Sheet


by Ryan Johnson (CITguy) via cheatography.com/138/cs/132/

usermod [options] LOGIN

groupadd [options] GROUP

-a, --append : Add user to supplementary

-f, --force : This option causes the command to

group(s). Use only with the -G option.

simply exit with success status if the specified

-d, --home HOME_DIR : The user's new login

group already exists.

directory.

-g, --gid GID : The numerical value of the

-e, --expiredate EXPIRE_DATE : Date on

groups ID. This value must be unique, unless

which the user account will be disabled (YYYY-

the -o option is used.

MM-DD)

-K, --key KEY=VALUE : Overrides

-g, --gid GROUP : The group name/number of

/etc/login.defs defaults (GID_MIN, GID_MAX

the user's new initial login group.


-G, --groups GROUP1[,GROUP2...] : A list of
supplementary groups which the user is also a

and others). Multiple -K options can be


specified.
-o, --non-unique : This option permits to add

member

a group with a non-unique GID.

-l, --login NEW_LOGIN : The name of the

-p, --password PASSWORD : The default is to

user will be changed from LOGIN to


NEW_LOGIN.
-L, --lock : Lock a users password. (Can't use
option with -p or -U)

disable the password. (NOT


RECOMMENDED: the password will be visible
by users listing the processes.)
-r, --system : Create a system group.

-m, --move-home : Move the content of the


users home directory to the new location.
-o, --non-unique : when used with the-u
option, this option allows to change the user ID
to a non-unique value.
-p, --password PASSWORD : Set password
explicitly via shell. Not recommended!
-s, --shell SHELL : The name of the users new
login shell.
-u, --uid UID : The new numerical value of the
users ID. Must be unique unless the -o option is
used.
-U, --unlock : Unlock a users password.(Can't
use this option with -p or -L.)
-Z, --selinux-user SEUSER : The SELinux
user for the users login.

By Ryan Johnson (CITguy)

Published 19th December, 2011.

Sponsored by Readability-Score.com

cheatography.com/citguy/

Last updated 20th December, 2011.

Measure your website readability!

Page 2 of 2.

https://readability-score.com

You might also like