Your IP : 216.73.216.40


Current Path : /var/www/html/bibhas.ghoshal/ITP_2019/lab/
Upload File :
Current File : /var/www/html/bibhas.ghoshal/ITP_2019/lab/Tut0.tex

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{color}
%opening
\title{Tutorial 0 : Compiling your first C program in the Linux Environment}
%\author{}

\begin{document}

\maketitle

\underline{\textbf{Objective : }}
\begin{itemize}
 \item This lab is intended to provide an introduction to Linux. The lab consists of performing basic system operations such as text editing and file management  in Linux environment. It also introduces the steps for compiling a C program. The objective of this lab is to make students familiar with the Linux command-line environment and develop the skills of shell scripting. This lab serves as a platform for the subsequent labs related to programming in C.
 %This assignment is intended to learn how to create, work with and manipulate processes in XV6. You are expected to refer to the text book and references mentioned in the course
 %website befor you start the lab. 
 %Some sample codes for process creation using \emph{fork} system call have been provided for your reference.\\
\end{itemize}

\underline{\textbf{Recommended Systems : }}
\begin{itemize}
 \item Any Flavour of Linux - We will be using Ubuntu Systems in the lab 5042
 %This assignment is intended to learn how to create, work with and manipulate processes in XV6. You are expected to refer to the text book and references mentioned in the course
 %website befor you start the lab. 
 %Some sample codes for process creation using \emph{fork} system call have been provided for your reference.\\
\end{itemize}

\underline{\textbf{References : }}
\begin{itemize}
 \item Unix concepts and applications, Fourth Edition, Sumitabha Das, TMH.
 \item Brian W. Kernighan and Dennis M. Ritchie,The C Programming Language, Prentice Hall of India.
 \item Byron Gottfried, Schaum’s Outline of Programming with C,McGraw-Hill.
\end{itemize}


\underline{\textbf{Getting Started}}\\
\begin{itemize}


\item Switch on your monitor.

\item Switch on your PC.
\item Allow the machine to boot. 

\item Wait until the log in prompt comes.

\item Supply your log-in and password
\begin{itemize}
 \item Log in : \emph{iiita}
 \item Password : \emph{iiita123}\\
 This opens your window manager(usually GNOME) with icons, the side panel, and so on. You are now ready to start your work
 
 \item Click on the terminal icon to open a shell (command prompt).
 
\end{itemize}

\underline{\textbf{Getting Used to Linux}}\\
\begin{itemize}


\item At the shell prompt type : \emph{echo HELLO WORLD}\\The word hello world would get displayed as output on the terminal. The \emph{echo} command displays a line of text. Type \emph{man echo} to read what an echo command does.


\item 2. Linux provides on-line manuals for different commands through an interface called \emph{man}. To know about \emph{man} type the following on the terminal:
\emph{man man} and read the description that is displayed.For all commands we will use the syntax \emph{man< command name >}
\item Type \emph{echo \$SHELL}: This prints \emph{/bin/bash} \textbf{ bash} is the name of the login shell that is currently in use

\item Some useful Unix commands : 
  \begin{itemize}
   \item Create a directory:mkdir progs
  \item Go to a new directory:cd progs/
  \item Go to the parent directory:cd ../
  \item List all files in a directory:ls -lF
  \item View a file:cat filename
  \item Copy a file to another:cp file1.c file2.c
  \item Copy a file to a directory:cp file1.c progs/file3.c
  \item Move a file to another:mv file1.c file2.c
  \item Move a file to a directory:mv file1.c progs/file3.c
  \item Delete a file:rm filename
  \end{itemize}

 
\end{itemize}












\underline{\textbf{Compiling Your First C Program}}\\
\begin{itemize}
\item Click on the terminal icon to open a shell (command prompt).
 \item Edit your program (new or already existing) by an editor. We recommend using the \emph{emacs} editor. This is how you can run emacs:\\
 
  \$\_ \emph{emacs  my\_first\_prog.c \& }\\
 

 
  (The ampersand in the last command was not necessary, but is helpful, because it runs emacs in the background and the shell is free to listen to your other commands. The file my\_first\_prog.c ha sbeen provided in the helpful resources section. Download it and save it in the working folder)\\

You can also use \emph{vim} or \emph{gedit} as the editors of your choice. In that case you will have to type : \\

  \$\_ \emph{gedit  my\_first\_prog.c \&} \\


or type :\\

  \$\_ \emph{vi  my\_first\_prog.c \& }\\
 

 \item Write your program in the editor and save it.

\item Go to the shell and compile your program:

   \emph{cc my\_first\_prog.c}

\item If compilation is successful, an executable called \emph{a.out} will be created.

\item Run your program:

\emph{ ./a.out}

\item Continue your edit-compile-debug-run-debug-print work. 
\end{itemize}




\end{itemize}




 


\end{document}