\input{gl2.slide-header-beamer}% \usepackage{calc,key,array,textcomp} %\usepackage{longtable} \usepackage{supertabular} %\errorcontextlines=99 \title{GNU and Linux commands} \date{5, 6 December 2005} \author[Nick Urbanik]{Nick Urbanik \texttt{}\\ {\scriptsize This document Licensed under GPL---see section~\ref{sec:license}}}% \subtitle{About my favourite file manager\\Linux for Teachers}% %\mode
{\chead{}}% \begin{document} \maketitle \mode
{\thispagestyle{empty}} \begin{frame} \frametitle{Outline} \mode {% %\footnotesize \begin{multicols}{2} \tableofcontents \end{multicols} % You might wish to add the option [pausesections] }% \mode
{% \tableofcontents }% \end{frame} \section{Why the Command Line?} \label{sec:why-free-software} \begin{frame} \frametitle{Why the Command Line?} \begin{itemize}[<+->] \item Isn't that going back to the dark ages? \item Don't file managers make all that obsolete? \item Doesn't it take so much longer to type all those crazy commands? \item ``Aren't you just telling us all this crap to waste our precious time we could spend learning something useful?'' \item I'll tell you a secret \end{itemize} \end{frame} % Bring umbrella to protect against rotten tomatoes \begin{frame} \frametitle{My Dirty Secret} \begin{itemize}[<+->] \item You may be better with a file manager than I am \item you may have had more practice than I have\ldots \item \ldots\,because my favourite file manager is the command line \begin{itemize} \item \ldots\,keeps umbrella handy to protect against the expected shower of rotten tomatoes \end{itemize} \item Still here? Hmm, okay, I'll tell you why. \end{itemize} \end{frame} \subsection{Advantages of the Command Line} \label{sec:advantages-of-command-line} \begin{frame} \frametitle{Advantages of the Command Line} \begin{itemize} \item Allows you to automate things \item Provides quick ways of getting at things similar to what you did before \item quicker than pulling down menus \end{itemize} \end{frame} \section{Comparing GNU commands with DOS} \label{sec:gnu-cf-dos} \begin{frame} \frametitle{Comparing GNU commands with DOS} \begin{itemize} \item You are nearly as old as I am, \item so many of you are familiar with DOS commands. \item If you were just out of school, this comparison would be useless \end{itemize} \end{frame} % \begin{frame}[allowframebreaks] % \frametitle{GNU \(\leftrightarrow\) DOS} % \newlength{\colwidth} % \setlength{\colwidth}{0.3333\textwidth-1.3333\tabcolsep} % \noindent% % \begin{longtable}{@{}% % >{\raggedright\hspace{0pt}\arraybackslash}p{\colwidth}% % >{\raggedright\hspace{0pt}\arraybackslash\ttfamily}p{\colwidth}% % >{\raggedright\hspace{0pt}\arraybackslash\ttfamily}p{\colwidth}@{}} % \toprule% % \textbf{Action} & \textnormal{\textbf{GNU}} & % \textnormal{\textbf{DOS}} \\ % \midrule% % \endfirsthead% % \toprule% % \textbf{Action} & \textnormal{\textbf{GNU}} & % \textnormal{\textbf{DOS}} \\ % \midrule% % \endhead% % \bottomrule% % \multicolumn{3}{r@{}}{\emph{Continued\ldots}} % \endfoot% % \bottomrule% % \endlastfoot% % list files (short) & ls & dir /s\\ % list files (long) & ls -l & dir \\ % copy files & cp \meta{sourcefile} \ldots\ \meta{target} & copy % \meta{sourcefile} \meta{target}\\ % move files & mv \meta{sourcefile} \ldots\ \meta{target} & move % \meta{sourcefile} \meta{target} \\ % rename files & mv \meta{sourcefile} \meta{target} & ren % \meta{sourcefile} \meta{target} \\ % change directory & cd \meta{dirname} & cd \meta{dirname} \\ % make directory & mkdir \meta{dirname} \ldots & md \meta{dirname}\\ % remove directory & rmdir \meta{dirname} \ldots & rd \meta{dirname}\\ % show current directory& pwd & cd \\ % show content of text file & cat \meta{file} & type \meta{file} \\ % \end{longtable} % \end{frame} %\mode
% \begin{frame} % \frametitle{GNU \(\leftrightarrow\) DOS} % \newlength{\colwidth} % \setlength{\colwidth}{0.3333\textwidth-1.3333\tabcolsep} % \tablehead{% % \toprule% % \textbf{Action} & \textnormal{\textbf{GNU}} & % \textnormal{\textbf{DOS}} \\ % \midrule% % }% % \tabletail{% % \bottomrule% % %\multicolumn{3}{r@{}}{\emph{Continued\ldots}\\} % }% % \tablelasttail{% % \bottomrule% % }% % \noindent% % \begin{tabular}{@{}% % >{\raggedright\hspace{0pt}\arraybackslash}p{\colwidth}% % >{\raggedright\hspace{0pt}\arraybackslash\ttfamily}p{\colwidth}% % >{\raggedright\hspace{0pt}\arraybackslash\ttfamily}p{\colwidth}@{}} % \toprule % \textbf{Action} & \textnormal{\textbf{GNU}} & % \textnormal{\textbf{DOS}} \\ % \midrule % list files (short) & ls & dir /s\\ % list files (long) & ls -l & dir \\ % copy files & cp \meta{sourcefile} \ldots\ \meta{target} & copy % \meta{sourcefile} \meta{target}\\ % move files & mv \meta{sourcefile} \ldots\ \meta{target} & move % \meta{sourcefile} \meta{target} \\ % rename files & mv \meta{sourcefile} \meta{target} & ren % \meta{sourcefile} \meta{target} \\ % \end{tabular} % \end{frame} % \begin{frame} % \frametitle{GNU \(\leftrightarrow\) DOS} % \newlength{\colwidth} % \setlength{\colwidth}{0.3333\textwidth-1.3333\tabcolsep} % \noindent% % \begin{tabular}{@{}% % >{\raggedright\hspace{0pt}\arraybackslash}p{\colwidth}% % >{\raggedright\hspace{0pt}\arraybackslash\ttfamily}p{\colwidth}% % >{\raggedright\hspace{0pt}\arraybackslash\ttfamily}p{\colwidth}@{}} % \toprule % \textbf{Action} & \textnormal{\textbf{GNU}} & % \textnormal{\textbf{DOS}} \\ % \midrule % change directory & cd \meta{dirname} & cd \meta{dirname} \\ % make directory & mkdir \meta{dirname} \ldots & md \meta{dirname}\\ % remove directory & rmdir \meta{dirname} \ldots & rd \meta{dirname}\\ % show current directory& pwd & cd \\ % show content of text file & cat \meta{file} & type \meta{file} \\ % \bottomrule% % \end{tabular} % \end{frame} % \mode \begin{frame} \frametitle{GNU \(\leftrightarrow\) DOS} \newlength{\colwidth} \setlength{\colwidth}{0.3333\textwidth-1.3333\tabcolsep} % \tablehead{% % \toprule% % \textbf{Action} & \textnormal{\textbf{GNU}} & % \textnormal{\textbf{DOS}} \\ % \midrule% % }% % \tabletail{% % \bottomrule% % %\multicolumn{3}{r@{}}{\emph{Continued\ldots}\\} % }% % \tablelasttail{% % \bottomrule% % }% \noindent% \begin{tabular}{@{}% >{\raggedright\hspace{0pt}\arraybackslash}p{\colwidth}% >{\raggedright\hspace{0pt}\arraybackslash\ttfamily}p{\colwidth}% >{\raggedright\hspace{0pt}\arraybackslash\ttfamily}p{\colwidth}@{}} \toprule \textbf{Action} & \textnormal{\textbf{GNU}} & \textnormal{\textbf{DOS}} \\ \midrule list files (short) & ls & dir /s\\ list files (long) & ls -l & dir \\ copy files & cp \meta{sourcefile} \ldots\ \meta{target} & copy \meta{sourcefile} \meta{target}\\ move files & mv \meta{sourcefile} \ldots\ \meta{target} & move \meta{sourcefile} \meta{target} \\ rename files & mv \meta{sourcefile} \meta{target} & ren \meta{sourcefile} \meta{target} \\ \bottomrule% \end{tabular} \end{frame} \begin{frame} \frametitle{GNU \(\leftrightarrow\) DOS} %\newlength{\colwidth} \setlength{\colwidth}{0.3333\textwidth-1.3333\tabcolsep} \noindent% \begin{tabular}{@{}% >{\raggedright\hspace{0pt}\arraybackslash}p{\colwidth}% >{\raggedright\hspace{0pt}\arraybackslash\ttfamily}p{\colwidth}% >{\raggedright\hspace{0pt}\arraybackslash\ttfamily}p{\colwidth}@{}} \toprule \textbf{Action} & \textnormal{\textbf{GNU}} & \textnormal{\textbf{DOS}} \\ \midrule change directory & cd \meta{dirname} & cd \meta{dirname} \\ make directory & mkdir \meta{dirname} \ldots & md \meta{dirname}\\ remove directory & rmdir \meta{dirname} \ldots & rd \meta{dirname}\\ show current directory& pwd & cd \\ show content of text file & cat \meta{file} & type \meta{file} \\ \bottomrule% \end{tabular} \end{frame} \section{Isn't it too slow?} \label{sec:too-slow} \begin{frame} \frametitle{Doing it fast} \begin{itemize} \item Bash shell provides command-line editing \begin{itemize} \item Move: \key{Home}, \key{End}, \key{$\leftarrow$}, \key{$\rightarrow$} \item Delete words: \key{Esc}\key{D}, \key{Esc}\key{Backspace} \item Delete to end of line: \key{Control-k} \end{itemize} \item tab completion \begin{itemize} \item type the first few characters of a command, file,\,\ldots\, and press the \key{Tab} key: the shell will complete the name \end{itemize} \item A history of previous commands \begin{itemize} \item press \key{$\uparrow$}, \key{$\downarrow$} \end{itemize} \item \textbf{\underline{R}}everse search through history \begin{itemize} \item type any characters from a previous command and press \key{Control-R} repeatedly until you see the command you want \end{itemize} \end{itemize} \end{frame} \subsection{Doing it even faster} \label{sec:faster} \begin{frame} \frametitle{Doing it even faster with loops} \begin{itemize} \item command line editing, tab-completion and history all make the command line fast\ldots \item \ldots\, but the real speed comes with automation \item We can automate things with loops \item Here are the last few things I did with loops: \mode{\footnotesize}% \item \textbf{list PDF documents I wrote, with the number of pages:} \sloppypar\cmd{for i in *trans.pdf;do o="\$(pdfinfo \$i|egrep '\textasciicircum{}Pages:|\textasciicircum{}Author:|\textasciicircum{}Title:')";if echo \$o| egrep -q 'Author: +Nick';then echo \$i:;echo "\$o";fi;done} \item \textbf{Set timestamp correctly in family photos:} \sloppypar\cmd{for i in 2005\_09\_11 2005\_09\_12 2005\_09\_13 2005\_09\_14 2005\_09\_15 2005\_09\_16 2005\_09\_17 2005\_09\_18;do pushd \$i;pwd;exif-timestamp-adjust.pl *.jpg;popd;done} \item \textbf{View all my teaching handouts:} \sloppypar\cmd{for i in *slides-beamer-handout.pdf;do xpdf \$i\&done} \item \textbf{Pretty-print my C++ programs:} \sloppypar\cmd{for i in *.cpp;do pretty-print-cpp \$i| lpr;done} \item \textbf{Make a hundreds table for my son:} \sloppypar\cmd{for ((i=1;i<=100;++i));do echo -n "\$i~"; if ((i \% 10 == 0));then echo '\\';else echo -n '\&~';fi;done > hundreds-table.tex} \end{itemize} \end{frame} \section{How can I get help with these commands?} \label{sec:help-with-commands} \begin{frame} \frametitle{How can I get help with these commands?} \begin{itemize} \item A few commands are built into the \texttt{bash} shell; you can get help for these by typing \cmd{help} \item The other commands are in \texttt{/bin}, \path{/usr/bin} \item you can go there and have a look \item each one has a ``\eblue{\texttt{man} page}'' \item To read the page for \texttt{ls}, you can do \cmdbox{man ls} \item To search for \meta{word} in the \texttt{man} page, type \texttt{/\meta{word}} \item To quit, type: \key{q} \end{itemize} \begin{block}{But where is the woman command? Isn't this sexist?} \begin{itemize} \item ``\texttt{man}'' is short for ``manual'' \end{itemize} \end{block} \end{frame} %\subsection{But where is the woman command? Isn't this sexist?} %\label{sec:woman-command} \section{What's the GNU, anyway?} \label{sec:what-is-gnu} \begin{frame} \frametitle{What's the GNU, anyway?} \includegraphics[width=0.3\linewidth]{gnu-head} \begin{itemize} \item GNU stands for ``GNU's Not Unix'' \item It's the project started by Richard Stallman \item Aims to provide all we need without contaminating our computers with non-free software \item Enables membership of the Church of Emacs. \end{itemize} \end{frame} % \begin{frame} % \frametitle{} % \begin{itemize} % \item % \end{itemize} % \end{frame} \section{Some Things to Do} \label{sec:things-to-do} \begin{frame} \frametitle{Some things to do} \begin{itemize} \item Write a \texttt{for} loop to count up to 100: \cmd{for ((i = 0; i <= 100; ++i));do echo \$i;done} \item See all the \texttt{man} pages for programs in \texttt{/bin}: \cmd{cd /bin; for i in *;do man \$i;done} \item Do the same thing for the commands in \texttt{/usr/bin} \item Note: pressing \key{Control-C} will interrupt a loop that gets stuck going ``forever'' \end{itemize} \end{frame} \section{Being the System Administrator} \label{sec:system-administrator} \begin{frame} \frametitle{Being the system administrator} \begin{itemize} \item You write to anything under your home directory, or in \texttt{/tmp} with your own account \item \ldots\,but to write anywhere else, you need to be the system administrator and have \texttt{root} access. % \item You can use \texttt{yum} to install new software on Fedora. % \item However, you need to be the system administrator % (\texttt{root}) to do that. %\item However, we have a CD with some tarballs on it. \item I highly recommend that you use \texttt{sudo} to become the system adminstrator. \item To do that you can follow the separate guide available at \url{http://nicku.org/lpic102/lpic/general-linux-2/lab/sudo/sudo.pdf} \end{itemize} \end{frame} \subsection{Getting more software} \label{sec:getting-more-software} \begin{frame} \frametitle{Getting more software} \begin{itemize} \item You can use \texttt{yum} to install new software \item You can become \texttt{root} by either: \begin{itemize} \item using \texttt{sudo} \tick \item \ldots\, or by typing \cmd{su -} and then entering the \texttt{root} password \cross \end{itemize} %\item However, we have a CD with some tarballs on it. \item Then do: \cmdbox{sudo yum -y update} or \mbox{\rootcmd{yum -y update}} \item To install Blender, do: \cmdbox{sudo yum -y install blender} \item To install Scribus, do: \cmdbox{sudo yum -y install scribus} \end{itemize} \end{frame} \section{Some Things to Read} \label{sec:things-to-read} \begin{frame}%[allowframebreaks] \mode{\frametitle{Resources}}% \begin{thebibliography}{5} % None of these affects how cite appears, only how the bibitem appears. % \beamertemplatebookbibitems makes little pictures of books in bib. \beamertemplatebookbibitems % \beamertemplatearticlebibitems makes little pictures of text in bib. % \beamertemplatearticlebibitems % \beamertemplatetextbibitems uses [1], [2] or [optional] in bib. % \beamertemplatetextbibitems % \beamertemplatearrowbibitems make little arrows (like ordinary items) % \beamertemplatearrowbibitems \bibitem{Wil2002} Dr. Peter Salus. \newblock% \emph{The Daemon, the GNU \& the Penguin}. \newblock% Grocklaw 2005. \newblock% \url{http://www.groklaw.net/staticpages/index.php?page=20051013231901859}. \beamertemplatearticlebibitems% \bibitem{GPL2} GNU General Public License. \newblock% \url{http://www.gnu.org/copyleft/gpl.html} \end{thebibliography} \end{frame} \mode {% \begin{frame} \frametitle{Topics Covered} %\footnotesize %\begin{multicols}{2} \tableofcontents[pausesections,pausesubsections] %\end{multicols} % You might wish to add the option [pausesections] \end{frame} } \section{License Of This Document} \label{sec:license} \begin{frame} \frametitle{License Of This Document} \raggedright% Copyright \copyright\ 2005 Nick Urbanik \par You can redistribute modified or unmodified copies of this document provided that this copyright notice and this permission notice are preserved on all copies under the terms of the GNU General Public License as published by the Free Software Foundation---either version 2 of the License or (at your option) any later version. \end{frame} \end{document}