2INC0 Operating Systems Introduction to Linux Joris Geurts
practical schedule week 1: introduction Linux introduction C practical next weeks: explanation assignment 1/2/3
What is Linux?
characteristics developed in 1970's by Ritchie and Thomson multi user multi tasking
advantages different hardware: IBM, Mips, Intel, ARM simple structure elaborate software tooling command interpreter: the SHELL principles applied in a consequent way
disadvantages cryptic names, e.g.: cat filename cryptic syntax: \ / * $ " ' ` ~ e.g.: grep "*.$1" `pick *.c` | lpr many members of the family, and they differ (Debian, Red Hat, Ubuntu, OpenSuse, Fedora, etc.)
Unix family tree August 31, 2010 Joris Geurts
Some Unix characteristics ‘Everything is a file’ including screen, mouse, hard disk etc. All (system) commands are just applications including login procedure, file and directory management, large and powerful set of commands The central role of the shell (command interpreter) typing rather than clicking Built-in management of different users multi-tasking and multi-user
Linux take-off August 31, 2010 Joris Geurts
Linux family tree
Linux distributions (600+) kernel + libraries + software applications August 31, 2010 Joris Geurts
Linux desktop environments Unity KDE GNOME
Using Linux: virtualization VMware Linux Ubuntu image
commands in a shell interaction with the OS, e.g.: ls date whoami cal
Command summary Joris Geurts Commands (find out their functionality) ls mkdir, cp, mv, which, chmod, echo, grep, pwd, cat, ps man input/output redirect ls > file command1 | command2 | command3 cat /etc/passwd | sort | less less /etc/passwd editors kate, gedit, vi (to be installed) emacs, joe, nano, eclipse Joris Geurts
Practical assignments (shell) Startup and login to the system Username: student Password: student Create a directory in Your home directory (/home/student/) The temporary directory (/tmp/) The root directory (/) Copy the password file to your home directory Search where the ls binary is located Determine its owner and permissions Record this information in a file Do a tutorial Install Dropbox (via Software Center) Joris Geurts
C programming language Language of the Linux kernel and many of the applications Low-level No memory protection No garbage collection No decent string type Direct memory pointer manipulation High execution performance possible At the cost of a longer development time 17
importance of C source: www.langpop.com
Hello World see http://www.fhict.nl/docent/downloads/2INC0/ compile and run $ gcc -o helloworld helloworld.c $ ./helloworld printf int i = 73; printf ("Hello World\n"); printf ("decimal display: %d\n", i); printf ("hexadecimal display: %04x\n", i); debugger… Joris Geurts
Debugging with nemiver sudo apt-get install nemiver (only once; already done) gcc -g –Wall –o myapp myapp.c nemiver myapp & set breakpoints run, step, etc. inspect variables Joris Geurts 20
Pointers in C roughly said: C pointer = Java reference C struct = Java object with public variables, without methods Practical: see the comments in helloworld.c for extra assignments Joris Geurts 21