Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Linux Orientation at VIIT Pune

Linux Orientation at VIIT Pune

Linux Orientation Session for Second Year Students at VIIT Pune

Prathamesh Sonpatki

June 26, 2012
Tweet

More Decks by Prathamesh Sonpatki

Other Decks in Education

Transcript

  1. Linux Basics Writing Programs Debugging Programs Communication Guidelines Linux Orientation

    Workshop For Second Year Computer Engineering Students Abdulkarim Memon (VIT, Final Year) Akshay Mankar (VIIT, Alumnus) Imran Ahmed (JSCoE, ALumnus) Miheer Vaidya (VIT, Final Year) Prathamesh Sonpatki (VIT, Alumnus) Vishwakarma Institute of Information Technology 27th Jun 2012 c GNU Free Document Licnese Vishwakarma Institute of Information Technology Linux Orientation Workshop – 1/23
  2. Linux Basics Writing Programs Debugging Programs Communication Guidelines Outline 1

    Linux Basics What is Linux The Filesystem Shell Basic Commands 2 Writing Programs What We Need Write a program Compile and Run 3 Debugging Programs Introduction Debugger Operations Debug Tricks ddd c GNU Free Document Licnese Vishwakarma Institute of Information Technology Linux Orientation Workshop – 2/23
  3. Linux Basics Writing Programs Debugging Programs Communication Guidelines Outline (cont.)

    4 Communication Guidelines Mailing Lists IRC c GNU Free Document Licnese Vishwakarma Institute of Information Technology Linux Orientation Workshop – 3/23
  4. Linux Basics Writing Programs Debugging Programs Communication Guidelines What is

    Linux • Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution.1 • Available in various Distros bundled with various other free software • Ubuntu • Fedora • Linux Mint • ... • Started by Linus Torvalds in 1991 c GNU Free Document Licnese Vishwakarma Institute of Information Technology Linux Orientation Workshop – 4/23
  5. Linux Basics Writing Programs Debugging Programs Communication Guidelines The Filesystem

    • Follows Filesystem Hierarchy Standard (FHS) • / : Root directory of entire filesystem • /bin : Essential command binaries • /dev : Essential Devices • /etc : System wide configurations • /home : User’s home directories • /lib : Libraries essential for binaries • /media : Mount points for removable media • /mnt : Temporary mounted filesystems • /opt : Optional Applications • /root : Home directory for root user • /sbin : Essential System Binaries • /tmp : Temporary files • /usr : Secondary hierarchy for read-only user data • /var : Variable Files c GNU Free Document Licnese Vishwakarma Institute of Information Technology Linux Orientation Workshop – 5/23
  6. Linux Basics Writing Programs Debugging Programs Communication Guidelines Screenshot c

    GNU Free Document Licnese Vishwakarma Institute of Information Technology Linux Orientation Workshop – 6/23
  7. Linux Basics Writing Programs Debugging Programs Communication Guidelines Shell •

    Interface between user and kernel • Can be command line (eg. Bash, Csh, Zsh, etc.) or can be graphical (eg. Gnome, KDE, etc.) Figure: Bash c GNU Free Document Licnese Vishwakarma Institute of Information Technology Linux Orientation Workshop – 7/23
  8. Linux Basics Writing Programs Debugging Programs Communication Guidelines Basic Commands

    • ls : List files and directories • cd : Change Directory • pwd : Print Working Directory • mkdir : Make Directory • cp : Copy Files • mv : Move Files • rm : Remove Files • cat : Concatenate files and print • touch : Change file timestamps • less : View files • man : Read reference manuals c GNU Free Document Licnese Vishwakarma Institute of Information Technology Linux Orientation Workshop – 8/23
  9. Linux Basics Writing Programs Debugging Programs Communication Guidelines Special Symbols

    • * : All files • \ : Escape Character • ˜ : Home • . : Current Directory • .. : Parent Directory c GNU Free Document Licnese Vishwakarma Institute of Information Technology Linux Orientation Workshop – 9/23
  10. Linux Basics Writing Programs Debugging Programs Communication Guidelines Redirection •

    < and > : Redirect • << and >> : Append • | : Pipe c GNU Free Document Licnese Vishwakarma Institute of Information Technology Linux Orientation Workshop – 10/23
  11. Linux Basics Writing Programs Debugging Programs Communication Guidelines What We

    Need • Editor : gedit, kate, vim, emacs. • Compiler : GNU Compiler Collection (gcc) • Debugger : GNU Debugger (gdb) c GNU Free Document Licnese Vishwakarma Institute of Information Technology Linux Orientation Workshop – 11/23
  12. Linux Basics Writing Programs Debugging Programs Communication Guidelines Write a

    program • Create directory /home/student/sum/ • Create a file sum.c • Open the File • Write a Program in C to calculate sum on n numbers. c GNU Free Document Licnese Vishwakarma Institute of Information Technology Linux Orientation Workshop – 12/23
  13. Linux Basics Writing Programs Debugging Programs Communication Guidelines Code 1

    //Program to Add N Numbers 2 #include <stdio.h> 3 int main() 4 { 5 int n,i,a[20],sum=0; 6 printf(”Enter No. of Numbers: ”); 7 scanf(”%d”,&n); 8 for(i=0;i<n;i++) 9 { 10 printf(”Enter a[%d]: ”,i ); 11 scanf(”%d”,&a[i]); 12 sum+=a[i]; 13 } 14 printf(”Sum = %d”,sum); 15 } c GNU Free Document Licnese Vishwakarma Institute of Information Technology Linux Orientation Workshop – 13/23
  14. Linux Basics Writing Programs Debugging Programs Communication Guidelines Compile and

    Run • Command to use: gcc • Syntax: gcc [options] input file.c • Options • -o : Output File • -Wall : Show all warnings • -c : Compile Only • Example $ gcc -o sum sum.c • Run $ ./sum c GNU Free Document Licnese Vishwakarma Institute of Information Technology Linux Orientation Workshop – 14/23
  15. Linux Basics Writing Programs Debugging Programs Communication Guidelines Debugging Programs

    • Debugger used: GNU Debugger (gdb) • Required For Debugging: • CPU Instructions : Required to execute • Symbol Table : Required to map higher level code with binary instructions • $ gcc -o sum sum.c will generate only Binary Executable • Use option -g to generate binary with symbol table • So the command is $ gcc -g -o sum sum.c • Start the Debugger by $ gdb sum c GNU Free Document Licnese Vishwakarma Institute of Information Technology Linux Orientation Workshop – 15/23
  16. Linux Basics Writing Programs Debugging Programs Communication Guidelines Debugger Operations

    • break : Set Breakpoints • run : Start Execution • step : Step into • next : Step over • print : Evaluate an expression • display : Set Watch • undisplay : Unset Watch • continue : Continue to next breakpoint or till end of program c GNU Free Document Licnese Vishwakarma Institute of Information Technology Linux Orientation Workshop – 16/23
  17. Linux Basics Writing Programs Debugging Programs Communication Guidelines Debug Tricks

    • b = break • r = run • s = step • n = next • p = print • Enter blank command to repeat last command • Get help: http://sourceware.org/gdb/current/onlinedocs/gdb/ c GNU Free Document Licnese Vishwakarma Institute of Information Technology Linux Orientation Workshop – 17/23
  18. Linux Basics Writing Programs Debugging Programs Communication Guidelines DDD -

    Data Display Debugger • A Simple to use GUI for gdb. • Also has gdb shell to support programmers c GNU Free Document Licnese Vishwakarma Institute of Information Technology Linux Orientation Workshop – 18/23
  19. Linux Basics Writing Programs Debugging Programs Communication Guidelines DDD -

    Data Display Debugger c GNU Free Document Licnese Vishwakarma Institute of Information Technology Linux Orientation Workshop – 19/23
  20. Linux Basics Writing Programs Debugging Programs Communication Guidelines Mailing Lists

    • PLUG http://www.plug.org.in/mailman/listinfo/plug-mail Pune Linux Users Group • CoFSUG groups.google.com/group/cofsug CoEP Free Software Users Group c GNU Free Document Licnese Vishwakarma Institute of Information Technology Linux Orientation Workshop – 20/23
  21. Linux Basics Writing Programs Debugging Programs Communication Guidelines IRC —

    Internet Relay Chat • On irc.freenode.net • #ubuntu - Ubuntu Community • #python - Python programmong language • ##c - C programming language • #viitlug - VIIT Linux Users group • #valu - VIT Linux Users group • #ppg-irc - PICT Pune Tech Group c GNU Free Document Licnese Vishwakarma Institute of Information Technology Linux Orientation Workshop – 21/23
  22. Linux Basics Writing Programs Debugging Programs Communication Guidelines Get More

    Help • dgp-lug summer training class logs http://wiki.dgplug.org/index.php/SummerTraining12#Class Logs • How to communicate using IRC on Fedora Wiki https://fedoraproject.org/wiki/How to communicate using IRC • Careers with GNU/Linux http://www.shakthimaan.com/downloads.html#careers-with- gnu-linux • Using git version control system http://www.shakthimaan.com/downloads.html#di-git-ally- managing-love-letters c GNU Free Document Licnese Vishwakarma Institute of Information Technology Linux Orientation Workshop – 22/23
  23. Linux Basics Writing Programs Debugging Programs Communication Guidelines Linux Orientation

    Workshop For Second Year Computer Engineering Students Abdulkarim Memon (VIT, Final Year) Akshay Mankar (VIIT, Alumnus) Imran Ahmed (JSCoE, ALumnus) Miheer Vaidya (VIT, Final Year) Prathamesh Sonpatki (VIT, Alumnus) Vishwakarma Institute of Information Technology 27th Jun 2012 c GNU Free Document Licnese Vishwakarma Institute of Information Technology Linux Orientation Workshop – 23/23