summaryrefslogtreecommitdiff
path: root/ult/ult_10
diff options
context:
space:
mode:
Diffstat (limited to 'ult/ult_10')
-rw-r--r--ult/ult_10/script.rst392
-rw-r--r--ult/ult_10/ult10.tex265
2 files changed, 657 insertions, 0 deletions
diff --git a/ult/ult_10/script.rst b/ult/ult_10/script.rst
new file mode 100644
index 0000000..28aa50e
--- /dev/null
+++ b/ult/ult_10/script.rst
@@ -0,0 +1,392 @@
+.. Objectives
+.. ----------
+
+ .. At the end of this tutorial, you will be able to:
+
+ .. 1. Search for files in many different ways
+ .. 2. Compare files with same names
+ .. 3. Create and extract an archive
+ .. 4. Customize a shell
+
+.. Prerequisites
+.. -------------
+
+.. 1. Getting started with Linux
+.. 2. Basic File Handling
+
+
+Script
+------
+
+.. L1
+
+{{{ Show the first slide containing title, name of the production
+team along with the logo of MHRD }}}
+
+.. R1
+
+Hello friends and Welcome to the tutorial on
+'Miscellaneous Tools'.
+
+.. L2
+
+{{{ Show slide with objectives }}}
+
+.. R2
+
+At the end of this tutorial, you will be able to,
+
+ 1. Search for files in many different ways.
+ #. Compare files with same names.
+ #. Create and extract an archive.
+ #. Customize a shell.
+
+.. L3
+
+{{{ Switch to the pre-requisite slide }}}
+
+.. R3
+
+Before beginning this tutorial,we would suggest you to complete the
+previous tutorials as being displayed currently.
+
+.. R4
+
+There are a bunch of tools, that will prove to be handy in your day
+to day work. These tools will help you quickly perform tasks like searching
+for files, comparing files and checking if they are the same, viewing the
+exact differences between them, etc.
+
+.. L4
+
+.. L5
+
+{{{ Show slide, find }}}
+
+.. R5
+
+Let us start with the first tool - 'find' .
+The ``find`` command lets you find files in a directory hierarchy. It
+offers a very complex feature set allowing you to search for files with a
+wide range of restrictions. We shall only look at some of the most
+frequently used ones.
+
+.. R6
+
+To find the files, which end with an extension, ``.pdf``, saved in the current
+folder and all it's subfolders, we say
+
+.. L6
+
+{{{ Open the terminal }}}
+::
+
+ find . -name "*.pdf"
+
+.. R7
+
+The ``find`` command also lists out the directory and sub-directory names
+To list them, we say,
+
+.. L7
+::
+
+ find . -type d
+
+.. R8
+
+In short, ``find`` allows you to set limits on file-size, modification time
+and whole lot of other things which you can explore on seeing the man page
+of ``find``.
+
+.. L8
+
+.. R9
+
+Let us now move on to the next tool, the compare tool.
+
+To compare two files, whether they are identical or not, we can use the
+``cmp`` command. Let us consider some situation. Suppose, we run the ``find``
+command to locate some file, and it turns out that we have a file with same
+name in different location.
+
+In this case, if we are unsure, whether both the files are the same, we can use
+the ``cmp`` command to check if the files are identical.
+
+.. L9
+::
+
+ find . -name quick.c
+ ./Desktop/programs/quick.c
+ ./c-folder/quick.c
+ cmp Desktop/programs/quick.c c-folder/quick.c
+
+.. L10
+
+{{{ Show slide, cmp }}}
+
+.. R10
+
+If the cmp command doesn't return any output, it means that both files are
+exactly identical. If there are any differences in the file, it gives you
+the exact byte location at which the first difference occurred.
+
+.. R11
+
+Let us now make a small change in one of quick.c file and run the ``cmp``
+command again.
+
+.. L11
+
+{{{ Switch to the terminal }}}
+
+::
+
+ cmp Desktop/programs/quick.c c-folder/quick.c
+
+.. R12
+
+As we can see, it gives the exact location as to where a change is made.
+
+Now, we may not be happy with just the knowledge that the files are
+different. We may want to see the exact differences between the two files.
+The ``diff`` command can be used to find the exact differences between the
+files.
+
+.. L12
+
+.. L13
+::
+
+ diff Desktop/programs/quick.c c-folder/quick.c
+
+.. R13
+
+We get back a line by line difference between the two files.
+
+.. L14
+
+{{{ Show slide, diff }}}
+
+.. R14
+
+The ``>`` mark indicates the content that has been added to the second file,
+which was not present in the first file. The ``<`` mark indicates the lines
+that were present in the first file, but are not existent in the second file.
+
+.. L15
+
+{{{ Show slide, tar }}}
+
+.. R15
+
+You would often come across (archive) files which are called *tarballs*. A
+tar ball is essentially a collection of files, which may or may not be
+compressed. Essentially, it eases the job of storing, backing up and
+transporting multiple files, at once.
+
+.. R16
+
+The following set of commands extracts the contents of the ``allfiles.tar``
+tarball to the directory extract.
+
+.. L16
+
+{{{ Switch to terminal }}}
+::
+
+ mkdir extract
+ cp allfiles.tar extract/
+ cd extract
+ tar -xvf allfiles.tar
+
+.. L17
+
+{{{ Show slide, extracting an archive }}}
+
+.. R17
+
+The option, ``x`` tells ``tar`` to extract the files in the archive file
+specified by the ``f`` option. The ``v`` option tells ``tar`` to give out a
+verbose output.
+
+.. R18
+
+Similarly, if we wish to create a ``tar`` archive, we use the ``c`` option
+instead of the ``x`` option. For instance, the command below creates an
+archive from all the files with the ``.txt`` extension.
+
+.. L18
+
+{{{ Switch to terminal }}}
+::
+
+ tar -cvzf newarchive.tar *.txt
+
+.. R19
+
+You can also create and extract compressed archives using ``tar``. It
+supports a wide variety of compressions like gzip, bzip2, lzma, etc.
+
+We need to add an additional option to ``tar`` to handle these
+compressions.
+
+
++-------------+------------+
+| Compression | Option |
++-------------+------------+
+| gzip | ``-z`` |
+| bzip2 | ``-j`` |
+| lzma | ``--lzma`` |
++-------------+------------+
+
+.. L19
+
+.. R20
+
+So, if we wished to create a gzip archive in the previous command, we
+change it to the following
+
+.. L20
+::
+
+ tar -cvzf newarchive.tar.gz *.txt
+
+.. L21
+
+{{{ Show slide, customizing your shell }}}
+
+.. R21
+
+What would you do, if you want bash to execute a particular command each
+time you start it up? For instance, say you want the current directory to
+be your Desktop instead of your home folder, each time bash starts up.
+Bash reads and executes commands in a whole bunch
+of files called start-up files, when it starts up.
+
+When bash starts up as an interactive login shell, it reads the files
+``/etc/profile``, ``~/.bash_profile``, ``~/.bash_login``, and
+``~/.profile`` in that order.
+
+When an interactive shell that is not a login shell is started, bash reads
+and executes commands from ~/.bashrc. This can be prevented using the ``--norc``
+option. Instead of using the ``~/.bashrc`` file on start-up, we can force
+the bash to use another file, for which the ``--rcfile`` option may be used.
+
+Now, you know what you should do, to change the current directory to you
+Desktop. Just put a ``cd ~/Desktop`` into your ``~/.bashrc`` and you are
+set!
+But as you know that the start-up files are used for a lot more complex things
+than this. You could set (or unset) aliases and a whole bunch of environment
+variables in the ``.bashrc``, like changing environment variables etc.
+
+.. L22
+
+{{{ Switch to 'Summary' slide }}}
+
+.. R22
+
+This brings us to the end of the end of this tutorial.
+In this tutorial, we have learnt to,
+
+ 1. Make use of the ``find`` command to find files in a directory hierarchy.
+ #. Find the differences between files with the same name, using the
+ ``cmp`` and ``diff`` commands.
+
+.. L23
+
+{{{ Switch to 'Summary..' slide }}}
+
+.. R23
+
+ #. Extract and create compressed archive's using the ``tar`` command.
+ #. Customize one's shell according to one's choice.
+
+.. L24
+
+{{{ Show self assessment questions slide }}}
+
+.. R24
+
+Here are some self assessment questions for you to solve
+
+ 1. Look at the man page of ``find`` and state the options which
+ deal with symbolic links.
+
+ 2. How do you append tar files to an archive?
+
+.. L25
+
+{{{ Solution of self assessment questions on slide }}}
+
+.. R25
+
+And the answers,
+
+1. The -H, -L and -P options with the ``find`` command control
+ the treatment of symbolic links.
+
+ 2. To append tar files to an archive, we can use the ``tar`` command
+ either with the ``-A`` option or the ``-r`` option, as,
+::
+
+ $ tar -Af <tar_file> <tar_file_to_be_added>
+ OR
+ $ tar -rf <tar_file> <tar_file_to_be_added>
+
+.. L27
+
+{{{ Show the SDES & FOSSEE slide }}}
+
+.. R27
+
+Software Development techniques for Engineers and Scientists - SDES, is an
+initiative by FOSSEE. For more information, please visit the given link.
+
+Free and Open-source Software for Science and Engineering Education - FOSSEE, is
+based at IIT Bombay which is funded by MHRD as part of National Mission on
+Education through ICT.
+
+.. L28
+
+{{{ Show the ``About the Spoken Tutorial Project'' slide }}}
+
+.. R28
+
+Watch the video available at the following link. It summarises the Spoken
+Tutorial project.If you do not have good bandwidth, you can download and
+watch it.
+
+.. L29
+
+{{{ Show the `` Spoken Tutorial Workshops'' slide }}}
+
+.. R29
+
+The Spoken Tutorial Project Team conducts workshops using spoken tutorials,
+gives certificates to those who pass an online test.
+
+For more details, contact contact@spoken-tutorial.org
+
+.. L30
+
+{{{ Show the ``Acknowledgements'' slide }}}
+
+.. R30
+
+Spoken Tutorial Project is a part of the "Talk to a Teacher" project.
+It is supported by the National Mission on Education through ICT, MHRD,
+Government of India. More information on this mission is available at the
+given link.
+
+.. L31
+
+{{{ Show the Thank you slide }}}
+
+.. R31
+
+Hope you have enjoyed this tutorial and found it useful.
+Thank you!
+
+
+
diff --git a/ult/ult_10/ult10.tex b/ult/ult_10/ult10.tex
new file mode 100644
index 0000000..9df5525
--- /dev/null
+++ b/ult/ult_10/ult10.tex
@@ -0,0 +1,265 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Using Linux Tools
+%
+% Author: FOSSEE
+% Copyright (c) 2009, FOSSEE, IIT Bombay
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\documentclass[17pt,compress]{beamer}
+\usepackage{beamerthemesplit}
+\mode<presentation>
+{
+ \usetheme{Warsaw}
+ \useoutertheme{infolines}
+ \setbeamercovered{transparent}
+ \setbeamertemplate{navigation symbols}{}
+}
+% Taken from Fernando's slides.
+\usepackage{ae,aecompl}
+\usepackage[scaled=.95]{helvet}
+
+\usepackage[english]{babel}
+\usepackage[latin1]{inputenc}
+\usepackage[T1]{fontenc}
+
+% change the alerted colour to LimeGreen
+\definecolor{LimeGreen}{RGB}{50,205,50}
+\setbeamercolor{structure}{fg=LimeGreen}
+\author[FOSSEE]{}
+\institute[IIT Bombay]{}
+\date[]{}
+% \setbeamercovered{transparent}
+
+% theme split
+\usepackage{verbatim}
+\newenvironment{colorverbatim}[1][]%
+{%
+\color{blue}
+\verbatim
+}%
+{%
+\endverbatim
+}%
+
+\usepackage{mathpazo,courier,euler}
+\usepackage{listings}
+\lstset{language=sh,
+ basicstyle=\ttfamily\bfseries,
+ showstringspaces=false,
+ keywordstyle=\color{black}\bfseries}
+
+% logo
+\logo{\includegraphics[height=1.30 cm]{../images/3t-logo.pdf}}
+\logo{\includegraphics[height=1.30 cm]{../images/fossee-logo.pdf}
+
+\hspace{7.5cm}
+\includegraphics[scale=0.99]{../images/fossee-logo.pdf}\\
+\hspace{281pt}
+\includegraphics[scale=0.80]{../images/3t-logo.pdf}}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% DOCUMENT STARTS
+\begin{document}
+
+\sffamily \bfseries
+\title
+[Miscellaneous Tools]
+{Miscellaneous Tools}
+\author
+[FOSSEE]
+{\small Talk to a Teacher\\{\color{blue}\url{http://spoken-tutorial.org}}\\\vspace{0.25cm}National Mission on Education
+ through ICT\\{\color{blue}\url{ http://sakshat.ac.in}} \\ [1.9cm]
+ Contributed by FOSSEE Team \\IIT Bombay \\[0.3cm]
+}
+
+% slide 1
+\begin{frame}
+ \titlepage
+\end{frame}
+
+
+\begin{frame}
+\frametitle{Objectives}
+\label{sec-2}
+
+At the end of this tutorial, you will be able to,
+\begin{itemize}
+\item Search for files in various ways
+\item Compare files with same names
+\item Create and extract an archive
+\item Customize a shell
+\end{itemize}
+\end{frame}
+
+\begin{frame}
+\frametitle{Pre-requisites}
+\label{sec-3}
+
+Spoken tutorial on,
+\begin{itemize}
+\item Getting started with Linux
+\item Basic File Handling
+\end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{`find'}}
+ \begin{itemize}
+ \item `find' command helps to find files in a directory hierarchy
+ \item Offers a very complex feature set\\ For eg: search files by name, owner, date,etc.
+ \item Look at the \texttt{man} page of `find'
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{`cmp'}}
+ \begin{lstlisting}
+ $ find . -name quick.c
+ ./Desktop/programs/quick.c
+ ./c-folder/quick.c
+ $ cmp Desktop/programs/quick.c
+ c-folder/quick.c
+ \end{lstlisting} % $
+ \begin{itemize}
+ \item No output when files are exactly same
+ \item Else, gives location where the first difference occurs
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{\texttt{`diff'}}
+ \begin{itemize}
+ \item We know the files are different, but want exact differences i.e. line by line
+ \end{itemize}
+\hspace{30pt}\verb~$diff Desktop/programs/quick.c ~\\
+\hspace{40pt}\verb~c-folder/quick.c~
+
+ \begin{itemize}
+ \item \texttt{>} indicates content only in second file
+ \item \texttt{<} indicates content only in first file
+ \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{\texttt{`tar'}}
+\begin{itemize}
+\item \emph{tarball} -- essentially a collection of files
+\item May or may not be compressed
+\item Eases the job of storing, backing-up \& transporting files
+\end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{Extracting an archive}
+\verb~mkdir extract~
+\verb~cp allfiles.tar extract/~
+\verb~cd extract~\\
+\verb~tar -xvf allfiles.tar~
+
+
+\begin{itemize}
+\item \texttt{-x} --- Extract files within the archive
+\item \texttt{-f} --- Specify the archive file
+\item \texttt{-v} --- Be verbose
+\end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Compressed archives}
+ \begin{itemize}
+ \item \texttt{tar} - create \& extract compressed archives
+ \item Additional option to handle compressed archives
+ \begin{center}
+ \begin{tabular}{|l|l|}\hline
+ Compression & Option \\\hline
+ gzip & \texttt{-z} \\\hline
+ bzip2 & \texttt{-j} \\\hline
+ lzma & \texttt{-{}-lzma} \\\hline
+ \end{tabular}
+ \end{center}
+ \end{itemize}
+\end{frame}
+
+
+\begin{frame}
+\frametitle{Customizing your shell}
+\begin{itemize}
+\item Bash reads \texttt{/etc/profile},
+ \texttt{\textasciitilde{}/.bash\_profile},
+ \texttt{\textasciitilde{}/.bash\_login}, and
+ \texttt{\textasciitilde{}/.profile} in that order, when starting
+ up as a login shell.
+\item \texttt{\textasciitilde{}/.bashrc} is read, when not a login
+ shell
+\end{itemize}
+\end{frame}
+
+
+\begin{frame}
+\frametitle{Summary}
+\label{sec-8}
+
+ In this tutorial, we have learnt to,
+
+
+\begin{itemize}
+\item Use ``find'' command to find files in a directory hierarchy
+\item Find differences between files with the same name, using the
+ ``cmp'' and ``diff'' commands
+\end{itemize}
+\end{frame}
+
+\begin{frame}
+\frametitle{Summary..}
+\label{sec-8}
+
+\begin{itemize}
+\item Extract and create compressed archive's using the ``tar'' command
+\item Customize one's shell according to one's choice
+\end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{Evaluation}
+\label{sec-9}
+
+
+\begin{enumerate}
+\item Look at the man page of ``find'' and state the options which
+ deal with symbolic links.
+\vspace{8pt}
+\item How do you append tar files to an archive ?
+\end{enumerate}
+\end{frame}
+\begin{frame}
+\frametitle{Solutions}
+
+\begin{enumerate}
+\item -H, -L and -P
+\vspace{15pt}
+\item \$tar -Af <tar-file><tar-file-to-be-added>
+\begin{center}
+OR \\
+\end{center}
+\$tar -rf <tar-file><tar-file-to-be-added>
+\end{enumerate}
+
+\end{frame}
+\begin{frame}
+
+ \begin{block}{}
+ \begin{center}
+ {\Large THANK YOU!}
+ \end{center}
+ \end{block}
+\begin{block}{}
+ \begin{center}
+ For more Information, visit our website\\
+ {\color{blue}\url{http://fossee.in/}}
+ \end{center}
+ \end{block}
+\end{frame}
+
+\end{document}
+
+
+