Unit-1: Introduction To Linux & C-Programming Language
Unit-1: Introduction To Linux & C-Programming Language
Unit-1: Introduction To Linux & C-Programming Language
Contents of Unit-1
1. 1 Brief History of C 1.2 Program Development Life Cycle 1. 3 Getting Started with Linux
History of C
C is structured, machine independent language ALGOL: -- introduced in 1960. -- root of all modern languages -- gave the concept of structured programming BCPL: Dennis Ritchie -- introduced in 1967. -- Basic combined programming language. -- used for writing system software.
3/4/2012 3
B:
introduced in 1970. used to create early versions of UNIX operating system both BCPL & B could deal with only specific problems C evolved from ALGOL, BCPL & B by Denis Ritchie at Bell laboratories in 1972 Today C is running under a variety of operating systems and hardware platforms.
3/4/2012
3/4/2012
C as a programming language
The basic characteristics of C are: Simple language loose typing (lots of freedom, error prone) structured (extensive use of functions) designed for systems programming close to the hardware. C as middle level language. can implement very efficient programs in a compact manner Case sensetive
3/4/2012
Why
Its ubiquitous (present anywhere) c is powerful and fast Low level functions yet provide high level language features Portable Modular Pointers and no type checking Very stable language (derivatives like c++, c#, Java) Favorite quote: c is its own virus.
3/4/2012 7
What c lacks
Automatic garbage collection Classes or objects with behavior Overloading and operator overloading Native support for multithreading and networking
3/4/2012
3/4/2012
Problem definition
What must the program do? What outputs are required and in what form? What inputs are available and in what form? The complete set of requirements and assumptions constitute the problem definition.
Program Design
Involves devising an algorithm Divide and conquer Top down approach used Each successive subdivision is referred to as a stepwise refinement
Program Coding
Program coding is the process of expressing the algorithm developed for solving a problem as a computer program in a programming language Use of structured programming improves understandability Use of combination of only three control structures: sequential, selective, and repetitive
Program Documentation
Refers to information about the program that specifies what is being done and how. It includes detailed --requirements of program -- layout of all output reports and input data -- top down decomposition -- algorithm for each component --input data used for testing --output of the test run.
3/4/2012
16
What is Linux?
Linux is an operating system Provides the interface between hardware (processor, peripherals, etc.), applications and the user
3/4/2012 17
History of Linux
Linux is an operating system that evolved from a kernel created by Linus Torvalds when he was a student at the University of Helsinki. Linus Torvalds decided to create his own operating system that would take into account users' comments and suggestions for improvements.
3/4/2012 18
3/4/2012
Why Linux ?
Free
Security Offloading job to a remote server Software availability Flexibility Performance Powerful command line
3/4/2012 20
3/4/2012
21
3/4/2012
22
File System
File System is developed for
create/store/load/delete/seek file on media Media example
Magnetic Media
Tape Floppy disk Hard disk
Optical Media
Cdrom Dvd
3/4/2012
24
3/4/2012
25
Windows
NTFS, FAT Each partition will be own root Ex. C:, D:, F:
Linux
ext2,ext3 Each partitions is mounted under /
3/4/2012
26
- first of mount point in linux /etc - keep linux default configuration /boot - keep important linux booting files /dev - keep all device files /usr - keep all user binary and X library /home - keep user home directory /proc - is pseudo file system for tracking running process and state of linux system /var - keeping mail, log file and printer spooling /lib - contain shared library that is required by system program /tmp - contain system temporary file
27
bin/
Dev/
etc/ home/
root/
tmp/
chris/
mary/
tom/
briefs/
personal/ memos/
3/4/2012
28
Ordinary Files
Directory Files
Special Files
Hard Links
Symbolic Links
3/4/2012
29
Basic Commands
$ pwd
/home/sbpatil
$ cd usr/bin $ cd .. $ cd or cd ~ =>takes to home dir $ cd ~/btech $ cd ../mbatech => to switchover betnween 2 dirs $ mkdir sbpatil $ rmdir sbpatil $ ls $ ls /home/sbpatil
30
3/4/2012
$ ls -l
1. 2. 3. 4. 5. 6. 7.
Detailed list
-rw-rw-r 1 sbpatil sbpatil 134 aug 27 11:45 btechcomputer D=directory, l / s=symbolic link File type, access permissions No. of links File owner Group owner (gp name) File size (in bytes) Day and time of last modification Name of file -a=includes hidden files -F=file type / dir, * exe -R=recursive listing-subdirs -r= reverse order -s=sort by file size
Exa. => $ ls -l a or $ ls -la
3/4/2012
31
$ cat file1 $ cat file1 file2 $ cp file1 file2 $ cp -r dir1 dir2 => recursively dir -all files $ rm file1 file2 $ rm r dir1 $ mv file1 file2 or dir1 dir2 => rename -i prompts before overwrite or remove $ more file1 $ less file1
Wildcards:
3/4/2012
32