\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Ryan Johnson (CITguy)} \pdfinfo{ /Title (nix-users-and-groups.pdf) /Creator (Cheatography) /Author (Ryan Johnson (CITguy)) /Subject (*nix users and groups Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{00CC00} \definecolor{LightBackground}{HTML}{EFFBEF} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{*nix users and groups Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Ryan Johnson (CITguy)} via \textcolor{DarkBackground}{\uline{cheatography.com/138/cs/132/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Ryan Johnson (CITguy) \\ \uline{cheatography.com/citguy} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 19th December, 2011.\\ Updated 13th May, 2016.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{passwd {[}options{]} {[}LOGIN{]}}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-a, -{}-all}} : This option can be used only with {\bf{-S}} and shows the status for all users.} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-d, -{}-delete}} : Delete a users password {\emph{(make it empty)}}.} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-e, -{}-expire}} : Immediately expire an account's password.} \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-i, -{}-inactive INACTIVE}} : This option is used to disable an account after the password has been expired for a number of days. {\emph{After an account has had an expired password for INACTIVE days, the user may no longer sign on to the account.}}} \tn % Row Count 11 (+ 5) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-k, -{}-keep-tokens}} : Indicate password change should be performed only for expired authentication tokens (passwords).} \tn % Row Count 14 (+ 3) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-l, -{}-lock}} : Lock the password of the named account. This does not disable the account. {\emph{The user may still be able to login using another authentication token (e.g. a SSH key).}}} \tn % Row Count 18 (+ 4) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-n, -{}-mindays MIN\_DAYS}} : Set the minimum number of days between password changes to MIN\_DAYS. {\emph{A value of zero indicates that the user may change their password at any time.}}} \tn % Row Count 22 (+ 4) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-S, -{}-status}} : Display account status information. ({\emph{login,locked/no/usable password,date of last password change,min age, max age, warning period, inactivity period}})} \tn % Row Count 26 (+ 4) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-u, -{}-unlock}} : Unlock the password of the named account.} \tn % Row Count 28 (+ 2) % Row 9 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-w, -{}-warndays WARN\_DAYS}} : Number of days warning prior to a required password change.} \tn % Row Count 30 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{passwd {[}options{]} {[}LOGIN{]} (cont)}} \tn % Row 10 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-x, -{}-maxdays MAX\_DAYS}} : Set the maximum number of days a password remains valid. {\emph{After MAX\_DAYS, the password will need to be changed.}}} \tn % Row Count 3 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{gpasswd {[}option{]} GROUP}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-a, -{}-add USER}} : Add the user to the named group.} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-d, -{}-delete USER}} : Remove the user from the named group.} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-r, -{}-remove-password}} : Remove the password from the named group.} \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-R, -{}-restrict}} : Restrict the access to the named group.} \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-A, -{}-administrators USER,...}} : Set the list of administrative users.} \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-M, -{}-members USER,...}} : Set the list of group members.} \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \columnbreak \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{useradd {[}options{]} LOGIN}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-b, -{}-base-dir BASE\_DIR}} : Default system base directory if {\bf{-d}} is not specified.} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-d, -{}-home HOME\_DIR}} : Use HOME\_DIR as the value for the user's login directory.} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-e, -{}-expiredate EXPIRE\_DATE}} : Date on which the user account will be disabled. ({\emph{YYYY-MM-DD}})} \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-f, -{}-inactive INACTIVE}} : Number of days after a password expires until the account is disabled. ({\emph{0 disables account on expiration. -1 disables the feature.}})} \tn % Row Count 10 (+ 4) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-g, -{}-gid GROUP}} : The group name or number of the users initial login group. {\emph{The group name must exist.}}} \tn % Row Count 13 (+ 3) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-G, -{}-groups GROUP1{[},...{]}}} : List of supplementary groups for the user. Subject to same restrictions as {\bf{-g}}.} \tn % Row Count 16 (+ 3) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-k, -{}-skel SKEL\_DIR}} : The skeleton directory to be copied in the users home directory, upon creation. {\emph{Only valid if {\bf{-m}} option specified}}} \tn % Row Count 19 (+ 3) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-K, -{}-key KEY=VALUE}} : Overrides /etc/login.defs defaults. {\emph{Multiple -K options can be specified.}}} \tn % Row Count 22 (+ 3) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-l, -{}-no-log-init}} : Do not add the user to the lastlog and faillog databases.} \tn % Row Count 24 (+ 2) % Row 9 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-m, -{}-create-home}} : Create the user's home directory if it doesn't exist.} \tn % Row Count 26 (+ 2) % Row 10 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-M}} : Don't create home directory.} \tn % Row Count 27 (+ 1) % Row 11 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-N, -{}-no-user-group}} : Do not create a group with the same name as the user.} \tn % Row Count 29 (+ 2) % Row 12 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-o, -{}-non-unique}} : Allow the creation of a user account with a duplicate UID. {\emph{Only valid along with {\bf{-u}} option}}} \tn % Row Count 32 (+ 3) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{useradd {[}options{]} LOGIN (cont)}} \tn % Row 13 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-p, -{}-password PASSWORD}} : The encrypted password. {\bf{NOT Recommended!}}} \tn % Row Count 2 (+ 2) % Row 14 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-r, -{}-system}} : Create system account} \tn % Row Count 3 (+ 1) % Row 15 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-s, -{}-shell SHELL}} : The name of the user's login shell.} \tn % Row Count 5 (+ 2) % Row 16 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-u, -{}-uid UID}} : The numerical value of the users ID. Must be unique unless {\bf{-o}} option used} \tn % Row Count 7 (+ 2) % Row 17 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-U, -{}-user-group}} : Create group with the same name as the user} \tn % Row Count 9 (+ 2) % Row 18 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-Z, -{}-selinux-user SEUSER}} : The SELinux user for the users login.} \tn % Row Count 11 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{groupmod {[}options{]} GROUP}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-g, -{}-gid GID}} : The group ID will be changed to GID.} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-n, -{}-new-name NEW\_GROUP}} : Group name will be changed from GROUP to NEW\_GROUP.} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-o, -{}-non-unique}} : When used with {\bf{-g}}, allows setting the group GID to a non-unique value.} \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-p, -{}-password PASSWORD}} : The encrypted password. {\bf{NOT Recommended!}}} \tn % Row Count 8 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \columnbreak \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{usermod {[}options{]} LOGIN}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-a, -{}-append}} : Add user to supplementary group(s). Use only with the {\bf{-G}} option.} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-d, -{}-home HOME\_DIR}} : The user's new login directory.} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-e, -{}-expiredate EXPIRE\_DATE}} : Date on which the user account will be disabled {\emph{(YYYY-MM-DD)}}} \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-g, -{}-gid GROUP}} : The group name/number of the user's new initial login group.} \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-G, -{}-groups GROUP1{[},GROUP2...{]}}} : A list of supplementary groups which the user is also a member} \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-l, -{}-login NEW\_LOGIN}} : The name of the user will be changed from LOGIN to NEW\_LOGIN.} \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-L, -{}-lock}} : Lock a users password. {\emph{(Can't use option with {\bf{-p}} or {\bf{-U}})}}} \tn % Row Count 14 (+ 2) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-m, -{}-move-home}} : Move the content of the users home directory to the new location.} \tn % Row Count 16 (+ 2) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-o, -{}-non-unique}} : when used with the {\bf{-u}} option, this option allows to change the user ID to a non-unique value.} \tn % Row Count 19 (+ 3) % Row 9 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-p, -{}-password PASSWORD}} : Set password explicitly via shell. {\bf{Not recommended!}}} \tn % Row Count 21 (+ 2) % Row 10 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-s, -{}-shell SHELL}} : The name of the users new login shell.} \tn % Row Count 23 (+ 2) % Row 11 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-u, -{}-uid UID}} : The new numerical value of the users ID. Must be unique unless the {\bf{-o}} option is used.} \tn % Row Count 26 (+ 3) % Row 12 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-U, -{}-unlock}} : Unlock a users password. {\emph{(Can't use this option with {\bf{-p}} or {\bf{-L}}.)}}} \tn % Row Count 28 (+ 2) % Row 13 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-Z, -{}-selinux-user SEUSER}} : The SELinux user for the users login.} \tn % Row Count 30 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \columnbreak \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{groupadd {[}options{]} GROUP}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-f, -{}-force}} : This option causes the command to simply exit with success status if the specified group already exists.} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-g, -{}-gid GID}} : The numerical value of the groups ID. {\emph{This value must be unique, unless the {\bf{-o}} option is used.}}} \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-K, -{}-key KEY=VALUE}} : Overrides /etc/login.defs defaults (GID\_MIN, GID\_MAX and others). {\emph{Multiple -K options can be specified.}}} \tn % Row Count 9 (+ 3) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-o, -{}-non-unique}} : This option permits to add a group with a non-unique GID.} \tn % Row Count 11 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{-p, -{}-password PASSWORD}} : The default is to disable the password. {\emph{({\bf{NOT RECOMMENDED}}: the password will be visible by users listing the processes.)}}} \tn % Row Count 15 (+ 4) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{-r, -{}-system}} : Create a system group.} \tn % Row Count 16 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}