\begin{exe} {Working with User Accounts}

   \begin{enumerate}

      \item
      Examine \filelink{/etc/passwd} and
      \filelink{/etc/shadow}, comparing the fields in each
      file, especially for the normal user account.
      What is the same and what is different?
      \item
      Create a \texttt{user1} account using
      \textbf{useradd}.
      \item
      Login as \texttt{user1} using \texttt{ssh}. You can
      just do this with:
      \begin{cmd}
$ ssh user1@localhost
      \end{cmd}
      It should fail because you need a password for \verb?user1?; it
      was never established.
      \item
      Set the password for \verb?user1? to \verb?user1pw? and
      then try to login again as \texttt{user1}.
      \item
      Look at the new records which were created in the
      \filelink{/etc/passwd}, \\ \filelink{/etc/group} and the
      \filelink{/etc/shadow} files.
      \item
      Look at the \filelink{/etc/default/useradd} file and see
      what the current defaults are set to. Also look at the
      \filelink{/etc/login.defs} file.
      \item
      Create a user account for \verb?user2? which will use the
      \textbf{Korn} shell (\textbf{ksh}) as its default shell.
      (if you do not have \textbf{/bin/ksh} install it or
      use the \textbf{C} shell at \textbf{/bin/csh}.)
      Set the password to \verb?user2pw?.
      \item
      Look at \filelink{/etc/shadow}.  What is the
      current expiration date for the \verb?user1? account?
      \item
      Use \textbf{chage} to set the account
      expiration date of \verb?user1? to December 1, 2013.

      Look at \filelink{/etc/shadow} to see what the
      new expiration date is.
      \item

      Use \textbf{usermod} to lock the \verb?user1?  account.

      Look at \filelink{/etc/shadow} and see what has
      changed about \verb?user1?'s password.  Reset the password to
      \texttt{userp1} on the account to complete this
      exercise.

   \end{enumerate}
   \begin{sol}

      \begin{enumerate}
         \item
         \begin{cmd}
$ sudo grep student /etc/passwd /etc/shadow
         \end{cmd}
         \begin{response}
/etc/passwd:student:x:1000:100:LF Student:/home/student:/bin/bash
/etc/shadow:student:$6$jtoFVPICHhba$iGFFUU8ctrtOGoistJ4/30DrNLi1FS66qnn0VbS6Mvm
  luKI08SgbzT5.IcOHo5j/SOdCagZmF2RgzTvzLb11H0:16028:0:99999:7:::
         \end{response}
         (You can use any normal user name in the place of
         \verb?student?.)  About the only thing that
         matches is the user name field.
         \item
         \begin{cmd}
$ sudo useradd user1
         \end{cmd}
         \item
         \begin{cmd}
$ ssh user1@localhost
         \end{cmd}
         \begin{response}
user1@localhost's password:
         \end{response}
         Note you may have to first start up the
         \textbf{sshd} service as in:
         \begin{cmd}
$ sudo service sshd restart
         \end{cmd}
         or
         \begin{cmd}
$ sudo systemctl restart sshd.service
         \end{cmd}
         \item
         \begin{cmd}
$ sudo passwd user1
         \end{cmd}
         \begin{response}
Changing password for user user1.
New password:
         \end{response}
         \item
         \begin{cmd}
$ sudo grep user1 /etc/passwd /etc/shadow
         \end{cmd}
         \begin{response}
/etc/passwd:user1:x:1001:100::/home/user1:/bin/bash
/etc/shadow:user1:$6$OBE1mPMw$CIc7urbQ9ZSnyiniVOeJxKqLFu8fz4whfEexVem2
   TFpucuwRN1CCHZ19XGhj4qVujslRIS.P4aCXd/y1U4utv.:16372:0:99999:7:::
         \end{response}
         \item
         On either \textbf{RHEL} or \textbf{openSUSE} systems for example:
         \begin{cmd}
$ cat /etc/default/useradd
         \end{cmd}
         \begin{response}
# useradd defaults file
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes
         \end{response}
         \begin{cmd}
$ cat /etc/login.defs
         \end{cmd}
         \begin{response}
....
         \end{response}
         We don't reproduce the second file as it is rather
         longer, but examine it on your system.
         \item
         \begin{cmd}
$ sudo useradd -s /bin/ksh user2
$ sudo passwd user2
         \end{cmd}
         \begin{response}
Changing password for user user2.
New password:
         \end{response}

         \item
         \begin{cmd}
$ sudo grep user1 /etc/shadow
         \end{cmd}
         \begin{response}
user1:$6$OBE1mPMw$CIc7urbQ9ZSnyiniVOeJxKqLFu8fz4whfEexVem2TFpucuwRN1CCHZ
   19XGhj4qVujslRIS.P4aCXd/y1U4utv.:16372:0:99999:7:::
         \end{response}
         There should be no expiration date.
         \item
         \begin{cmd}
$ sudo chage -E 2013-12-1 user1
$ sudo grep user1 /etc/shadow
         \end{cmd}
         \begin{response}
     user1:$6$OBE1mPMw$CIc7urbQ9ZSnyiniVOeJxKqLFu8fz4whfEexVem2TFpucuwRN1CCHZ
   19XGhj4qVujslRIS.P4aCXd/y1U4utv.:16372:0:99999:7::16040:
         \end{response}
         \item
         \begin{cmd}
$ sudo usermod -L user1

$ sudo passwd user1
         \end{cmd}

      \end{enumerate}
   \end{sol}
\end{exe}

