\begin{exe} {Controlling Processes with ulimit}

   Please do:
   \begin{cmd}
$ help ulimit
   \end{cmd}
   and read \filelink{/etc/security/limits.conf} before
   doing the following steps.

   \begin{enumerate}
      \item
      Start a new shell by typing \textbf{bash} (or opening
      a new terminal) so that your changes are only
      effective in the new shell.  View the current limit
      on the number of open files and explicitly view the
      hard and soft limits.
      \item
      Set the limit to the hard limit value and verify if
      it worked.
      \item
      Set the hard limit to 2048 and verify it worked.
      \item
      Try to set the limit back to the previous value.  Did
      it work?
   \end{enumerate}
   \begin{sol}

      \begin{enumerate}
         \item
         \begin{cmd}
$ bash
$ ulimit -n
         \end{cmd}
         \begin{response}
1024
         \end{response}
         \begin{cmd}
$ ulimit -S -n
         \end{cmd}
         \begin{response}
1024
         \end{response}
         \begin{cmd}
$ ulimit -H -n
         \end{cmd}
         \begin{response}
4096
         \end{response}
         \item
         \begin{cmd}
$ ulimit -n hard
$ ulimit -n
         \end{cmd}
         \begin{response}
4096
         \end{response}
         \item
         \begin{cmd}
$ ulimit -n 2048
$ ulimit -n
         \end{cmd}
         \begin{response}
2048
         \end{response}
         \item
         \begin{cmd}
$ ulimit -n 4096
         \end{cmd}
         \begin{response}
bash: ulimit: open files: cannot modify limit: Operation not permitted
         \end{response}
         \begin{cmd}
$ ulimit -n
         \end{cmd}
         \begin{response}
2048
         \end{response}
         You can't do this anymore!

         Note that if we had chosen a different limit, such
         as stack size (\verb?-s?)  we could raise back up
         again as the hard limit is \verb?unlimited?.
      \end{enumerate}
   \end{sol}
\end{exe}

