1 / 25

Handout # 2

Handout # 2. Linux. LINUX was created by Linus Torvalds in 1991 48% of US smartphone users use Android Used by a majority of webservers (65% use Apache, according to Netcraft, Apr 2012) 91% of the fastest 500 supercomputers run LINUX/UNIX has three most important parts.

hume
Download Presentation

Handout # 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Handout # 2

  2. Linux • LINUX was created by Linus Torvalds in 1991 • 48% of US smartphone users use Android • Used by a majority of webservers (65% use Apache, according to Netcraft, Apr 2012) • 91% of the fastest 500 supercomputers run • LINUX/UNIX has three most important parts. • They are Kernel, Shell and File System • Shell Types • Bourne Shell (sh) (First shell by Stephen Bourne) • C Shell(sh) • Korn Shell (ksh) • Bourne Again Shell(bash)

  3. File System • Linux files are organized by a hierarchy of labels, commonly known as hierarchy structure. • There are three types of files. • Regular Files: • This contains a sequence of bytes that generally corresponds to code or data. • Directory Files: • Directory file contains an entry for every file and subdirectory that it is placed. • Device Files: • These files correspond to the printers or other devices connected to the system.

  4. Standard directory structure • ◮ / - the topmost • ◮ /dev - all the devices are accessible as files • ◮ /var - “variable” data such as mails, log files, databases • ◮ /usr - almost all the packages installed • ◮ /etc - configuration files • ◮ /home - home directories for all the users • ◮ /root - home directory of the privileged user root • ◮ /mnt - used to mount other directories/partitions.

  5. Standard Directories in LINUX • Directory: /bin • /bin contains the binaries which are needed to run LINUX. • Directory: /boot • /boot has all the files required for booting LINUX on system. • Directory: /dev - /dev has the devices for all the files. • Directory: /etc • /etc contains the configuration files of the various software. • v Directory: /opt Here optional softwares are installed. • v Directory: /root The directory for the user root

  6. Standard Directories in LINUX • Directory: /home • /home is like My Documents in Windows. • Directory: /lib • /lib contains the libraries required fo r the system files. • Directory: /lost+found • /lost+found contains the files which are damaged or which are not linked to any directory • Directory: /mnt • This is the directory in which we mount the devices and other file systems.

  7. Linux GUI • Intro to Unity • ● Launcher (At the Left) • ● Menu Bar (At the Top) • ● Dash

  8. Application Software • OpenOffice • oowriter is a viewer and editor for MS Office like document files • ooimpress is used for preparing Power point like Presentations • oodraw is used for preparing drawings. • oocalc is used to open and edit Spreadsheet like xls or sxc files • firefox is used to open Mozilla web browser. • Editors • Editors are the one by which we can edit the files. • There are two types of editors and they are • Textual editor. • Graphical editor.

  9. Editors • The textual editors are • vi/vim • emacs • pico • The graphical editors are • gvim • emacs/xemacs • dtpad (CDE) • jot (SGI)

  10. Basic Commands • File and Directory Commands • Process Management • Archival • Advanced Commands • Keyboard Shortcuts

  11. File and Directory Commands • du – estimate file space usage • df – report filesystem disk space usage • quota – display disk usage and limits • fdisk – partition manipulator • mount – mount a file system

  12. File and Directory Commands • cd – changes directories • pwd print name of current working directory • ls - list directory contents • ls has many options: • -l à long list (Displays lots of info) • -t à lists by modification date • -S à lists by size • -h à lists file sizes in human readable format • -r à Reverse the order • -a à Lists all hidden files • -F à Lists files of Directory

  13. File and Directory Commands • Deleting Files - rm • Copying and moving files - cp, mv • Creating directories - mkdir • Deleting Empty Directory - rmdir • $ rm Testing.java • //deletes the file Testing.java • $ cp Testing.java Copy.java • //creates the copy of Testing.java • $ mv Testing.java Test.java • //renames the file Testing.java to Test.java • $ mkdir newDir • //Creates directory newDir • $ rmdir newDir • //deletes directory newDir newDir should be empty

  14. Process Management • ps – report a snapshot of the current processes • Usage: ps [OPTION] • eg. ps, • • kill – to kill a process(using signal mechanism) • Usage: kill [OPTION] pid • eg. kill 9

  15. Archival • tar – to archive a file • Usage: tar [OPTION] DEST SOURCE • • zip – package and compress (archive) files • Usage: zip [OPTION] DEST SOURSE • eg. zip original.zip original • • unzip – list, test and extract compressed files in a ZIP archive • Usage: unzip filename

  16. Advanced Commands • reboot – reboot the system • Usage: reboot [OPTION] • eg. reboot • • poweroff – power off the system • Usage: poweroff [OPTION] • eg. Poweroff • who command tells you the users currently logged on to the system • kuteer:˜$ who

  17. Keyboard Shortcuts • [Ctrl] e : moves cursor to the ending of the command • [Ctrl] a : moves the cursor to the starting of the command • [Ctrl] l : clears the command window. Functions like clear command. • [Ctrl] z :to suspend the process (moves the process into background ). bg can be used to find the background jobs. fg can be used to bring the background job into foreground. • [Ctrl] c or [ctrl] |: kill the process. • [Ctrl] u : erase the current line. • [Ctrl] k : erase the line from the position of cursor • [Ctrl] w : delete the word before the cursor

  18. Starting a Terminal • To open a Terminal do as follow: • Choose Applications → Accessories → Terminal; • Or press Alt+F2 and type gnome-terminal.

  19. Writing First Program in C/C++ in Ubuntu • Steps should apply to any Linux distribution • Install the build-essential package by typing the following command in the terminal: • sudo apt-get install build-essential

  20. Step 2 • Now create a file that has the extension .c • (if you plan to write a C program) or .cpp (for a C++ program). • for example /usr/src/first.c • sudo gedit first.c

  21. Step 3 • Write the code in that file • Example #include <stdio.h> int main () { printf("Hello, This is my First Program in Ubuntu !!!!"); return 0; }

  22. Step 4 • Now open a terminal and go to the place where you saved that file using the cd command (e.g. cd /usr/src/)

  23. Step 5 • If you have a C program type in the terminal • gcc -Wall -W -Werror first.c -o first • The first line will invoke the GNU C compiler to compile the file first.c and output (-o) it to an executable called first. • The options -Wall -W and -Werror instruct the compiler to check for warnings.

  24. Step 6 • If you have a C++ program simply replace gcc with g++ and first.c with first.cpp. The options do the same things • If you get a permissions error, you need to make the file executable. You can do this with chmod +x first.c or first.cpp

  25. Step 7 • Now type in the terminal ./first and the program will run • Repeat these steps for a C++ program

More Related