1 / 31

An Intro to Linux

An Intro to Linux. References: Slides “ Iinux ”, Dr. Farid Farahmand, Fall 2014 http://en.wikipedia.org/wiki/Linux http ://en.wikipedia.org/wiki/Unix http://en.wikipedia.org/wiki/ GNU https://en.wikipedia.org/wiki/ Comparison_of_text_editors https://en.wikipedia.org/wiki/ Gedit

channery
Download Presentation

An Intro to Linux

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. An Intro to Linux References: Slides “Iinux”, Dr. Farid Farahmand, Fall 2014 http://en.wikipedia.org/wiki/Linux http://en.wikipedia.org/wiki/Unix • http://en.wikipedia.org/wiki/GNU • https://en.wikipedia.org/wiki/Comparison_of_text_editors • https://en.wikipedia.org/wiki/Gedit http://distrowatch.com/ http://lifehacker.com/5774997/getting-started-with-linux-how-to-install-linux-on-your-computer • http://www.flexbeta.net/main/printarticle.php?id=70 • http://www.freeos.com/guides/lsst/ch01sec04.html http://www.freebsdsoftware.org/shells/ 6/23/2015

  2. It All Started With UNIX • Linux, an Operating System based on Unix • Unix was developed in 1970 by AT&T Lab (Later known as Bell Lab) • A multi-tasking & multi-user OS • AT&T licensed it to outside & the code of Unix was given to universities including UC Berkeley • UC Berkeley enhanced the existing version called it Berkeley Software Distribution Unix • SVR4 (System V Release 4) combines all Berkeley enhancements & original features • Unix was essentially for workstations 9/15/15

  3. Then Came Linux • Created in 1991 by Linus Torvalds , a software developer who became the chief architect of the Linux kernel • Small computers & PC-based operating system • Released in 1994 as Version 1 • Initially was developed for 80 & x86 processors (8080, 8086, .. i386) architecture processors) • Today it supports various processor & servers • AMD, Motorola 6800, Power PC, etc. • Runs on embedded systems, firmware, routers, mobile phones (Android), tablets, video game consoles 9/15/15

  4. Linux Distros = Linux Distribution • Each distro is a package including the OS & different applications • Different distros provide different applications & require different installations steps • The package includes • Core Linux OS (also called Kernel) • X Window System & GUI interfaces • Graphical desktop (e.g., GNOME or KDE) • Different applications • Word Processor, Spreadsheet, etc. • Documentations • Each Distro is under General Public License (GNU) • http://en.wikipedia.org/wiki/GNU • Anyone can copy & distribute the software in open source form to others, e.g. • Ubuntu “www.ubuntu.com” is an Open Source • Obtaining a distro can be through ready made packages over the net or buying the CD or just compiling a version 9/15/15

  5. Linux Distros - GNU • GNU is a free Operating System consisting of a kernel, libraries, system utilities, compilers, & end-user applications • "GNU's Not Unix", which was chosen because its design is Unix-like, but differs from Unix by being free software & by not containing any UNIX code 9/15/15

  6. Red Hat & Fedora Core • Fedora Project was introduced in 1993 to take over Red Hat Linux • Red Hat 9 was the last version • The new Linux distro called Fedora Core • A new version every six months! • 2004  Fedora Core 3 • 2005  Fedora Core 4 • New applications include OpenOffice, FireFox, GIMP (GNU Image Manipulation Program) • 2007  Fedora Core 6 • Fedora comes installed with Firefox 9/15/15

  7. Linux, Layered Views User User Application Programs Shell/Photo/WP/FTP/Telnet/ Web Browser User request Application Programmer Interface (API)- C/C++/Java/Fortran SHELL Application Operating System (Kernel) Lower Level Utilities Computer Hardware, I/O devices, Memory, CPU, Storage Devices LINUX KERNEL Computer Hardware 6/23/2015

  8. Linux Kernel • Kernel contains the actual Operating System (OS) • Manages processes in terms of creating, suspending, terminating, & maintenance • Schedules CPU • Provides inter-process communications & communicates with devices • Has many different versions • 1.x.y  Major. minor. patch • 2.6 is one of the most improved • Linux 2.6 Version improvements • Supports more hardware • Higher Stability • Supports 4 billion users & 16 TB File System! • Handles external devices better (supporting Hot Plug Devices, USB) • Supports many new devices (Wireless, USB-based, different storage devices using IDE, SCSI, ..) • Sound system • Higher security  Using SELinux (Security Enhanced Linux) 6/23/2015

  9. Linux Platform • Operating Systems are divided according to • How many users can use the system (logon) at the same time • The number of processors the system can run simultaneously • A process executing a program • Basic categories • Single User / Single Processor (Windows 3.1, DOS) • Single User / Multi Processor (Win NT Workstations, OS/2) • Multi User / Single Processor (Does it exist?) • Multi User / Multi Processor (Linux, Windows NT Server) • High resource utilization using multiplexing • Uses Time Sharing • High Throughput (Number of processes finished in a unit of time) • Uses multi-programming – If the current processes is accessing I/O, the CPU can be assigned to another task 9/15/15

  10. Linux Platform • A Linux shell, also called "the command line“ • Provides the traditional user interface for the Linux OS • Contains standard commands for Unix • Command are the instructions for the computer to do certain things • Good learning tool to learn Unix! • Basic Shells applications are • BASH, Bourne Shell • BASH is similar to Bourne Shell in Unix • C Shell, tcsh (TENEX C Shell), scsh (Scheme Shell) • http://www.freebsdsoftware.org/shells/ has list of various shells & their differences 9/15/15

  11. Basic Security In Linux • Without SELinux (Security Enhanced Linux) • Domains are divided into Users & Group IDs • The ROOT has absolute control • With SELinux • Domains are divided into Subjects & Objects • Even with Super-user privilege access to some files & devices maybe denied Logon as ROOT 9/15/15

  12. Linux Text Editors • A text editor is a type of program used for editing plain text files • Text editors are provided with operating systems & software development packages, & can be used to change: • configuration files, documentation files & programming languagesource code • Text editor allows to find, replace, cut & copy, filter, & format text in a program • There are many text editors that were & are used for Linux. • Wikipedia provides a good comparison • Come in form of Terminal Command Line Interface (CLI) or Graphic User Interface (GUI) • “vi”, CLI. developed by Bill Joy in C programing language for Unix OS, & Linux uses keyboard • Can put together with many commands, lines of code, to make a program. • “gedit”, CLI & GUI, like Windows Notepad uses mouse & keyboard, friendly 9/15/15

  13. Linux Desktop • Using the terminal commands is boring! • XWindow System or X • Is an open, cross-platform, client/server system & • Provides windowing system for graphic work stations • Based on a client/server model • Server handles input & output devices & • Generates graphical displays used by the clients • Was developed at MIT & some computer companies (X.org) • Uses mouse & keyboard • How the actual interface looks or feels depends on the GUI interface 9/15/15

  14. GUI Examples Choosing KDE (K-desktop Environment) at the Login Screen default GNOME Desktop The KDE Desktop (Fedora Core) 6/23/2015

  15. GEDIT Text Editor • Geditis Similar to Windows Notepad & the default GUI text editor in the Ubuntu OS • Can be invloked also in CLI • Designed for • Simplicity • Editing source code & structured text such as markup languages • Multi-language spell checking • Extensive support of syntax highlighting, & • A large #of official & 3rd party plugins • Freely available for Linux, Mac& Windows, by several developers An Ubuntu screen shot of GEDIT page 6/23/2015

  16. Ubuntu on Windows, Multi-OS Environment • 3 ways to install Ubuntu/Linux OS on your PC or laptop with Windows 7 or Mac OS. See http://lifehacker.com/5774997/getting-started-with-linux-how-to-install-linux-on-your-computer • Install Linux OS on a flash memory, then select Windows or Ubuntu/Linux as you boot your computer, OR • Install two different OS in two different partitions, in which case there is no access to each other, OR • Use an emulator, e.g., VMware that can install & run a copy of a second OS (Ubuntu/Linux) on the Hard Drive VMWare VPC/ WINE Host OS Guest OS Windows Linux 9/15/15

  17. Shell Prompt • Most work is done at the shell prompt which is the Command-Line Interface • Remember root is / • ls – list files • ls /mnt/floppy to see contents of floppy • cd – change directory • cd /home to go to folder home • mkdir – create a directory • Mkdirhomework to make a folder homework • Exercise: How can you go to CLI in: • Windows • Mac 9/15/15

  18. Shell Prompt • rmdir – remove a directory • rmdir /mnt/floppy/test • mv – move or rename a file • mv homework1 assignment1 • cp – copy a file • cphomework1 assignment1 • locate – find a file • locate homework1 • gedit <filename> - start editing a file • gedithomework1 • vi <filename> - start editing a file • vi homework1 9/15/15

  19. Shell Types The Linux Shell has evolved in several types, some are used, & some are not. Used: • bash — Bourne Again SHell, default shell in most Linux distributions, decent features, most common, freeware Shell • zsh— most feature rich, based on Bourne-style, still rarely used due to its complexity; developed by Paul Falstad in 1990 • ksh — default shell in Solaris, AIX & other few other unices; (Korn Shell by David Korn, AT&T) • tcsh — TENEX C shell, default shell in various *BSD flavor unices, used by those who know C programing language Basically most Shell types work basically the same with similar base commands Not Used (Historic): • sh — original Bourne shell (released 1977), developed by Steven Bourne, AT&T. Obsoleted by bash • csh — original C shell (released 1978), developed by Bill Joy, UCB. Obsoleted by tcsh & ksh • ash – a Bourne shell clone, light-weight (used in Android phone) by Kenneth Almquist • dash - a clone of ash developed by Debian • Can install & remove different shells using “Software Center” on Ubuntu • Shells can be changed by simply typing the name of the shell at the command prompt • chsh (change shell) 6/23/2015

  20. Linux Directory Hierarchy 6/23/2015

  21. Linux Directory Hierarchy 9/15/15

  22. Some Basic Commands Format: Command -optionargument • pwd(print working directory) • cd /bin • ls (List info about file(s) • ls –l (List detail info about file) • ls –a (show hidden files) • mkdirmyoffice • mkdir /root/mydocuments • rmdir office • wc(print word count) • date • man wc (get more information on wc command) • whatis man • whereistcsh(lists the path) • whoami • hostname • uname(displays system info) • E.g., uname–m (machine) • who (info about current user) • echo (display message on screen) • cat /etc/passwd • more /etc/passwd • man vi |more • cp/etc/passwdmypasswd • mv mypasswdyourpasswd • mv –i sample Make sure you can do these! 6/23/2015

  23. Finding/Displaying Files, Patterns • grep searches file(s) for words/lines that match a given pattern • E.g.., grep word? filename • grepcommand can display the IP address & machine name • find searches for files that meet a desired criteria • E.g., find xyz? (? For any xyz1, xyz2, xyz. ) • cat concatenates file & prints on the standard output • E.g., cat xyz • echo displays message on screen • E.g., echo hello 9/15/15

  24. Exercise Command + Options + Arguments • Open a shellterminal • Type the following, observe, & briefly explain what each does: • wc • date • man wc(get more info on wc command) • whatis man • whereiscsh(lists the path) • whoami • hostname • uname(linux) • who (information about current user) 9/15/15

  25. File System Permissions in Linux 9/15/15

  26. Linux Permissions • Permissions are set for user, group, & others • Each permission is set with a single digit from 0 to 7 (binary 000 to 111) on the combination of permissions • Examples for user, group, or others: • Read + write+ Execute = rwx = 4 + 2 + 1 = 7 • - + write+ Execute = -wx = 0 + 2 + 1 = 3 • Read + - + Execute = r-x = 4 + 0 + 1 = 5 • Read + write+ - = rw- = 4 + 2 + 0 = 6 9/15/15

  27. Using chmod to Set Permissions 9/15/15

  28. Linux Script Examples 1 Scriptis a collection of commands typed in text, stored in a file, read by processor and executed for result. One can use a text editor (e.g., vi) to make the file. Note: “$” is the Shell prompt & “#” indicates comments. Example 1: Write a Linux script to print sum of two numbers, let's say 6 and 3. $ echo 6 + 3This will print 6 + 3, not the sum 9. To do sum or math operations in shell use expr, syntax is as follows:Syntax: expr  op1   operator   op2 Where, op1 and op2 are any Integer Number (Number without decimal point) and operator can be +Addition- Subtraction/Division, to find quotient, 20 / 3 = 6 % Modular, to find remainder, 20 % 3 = 2 (Remember its integer calculation)\* Multiplication $ expr 6 + 3 # exprEvaluate expressions Now It will print sum as 9 , But$ expr 6+3will not work because space is required between number and operator (See Shell Arithmetic). 9/15/15

  29. Linux Script Example2 & 3 Notes: • $ with a space char after is the Linux prompt here • $ with NO space after defines a Linux variable Example 2: How to define two variable x=20, y=5 and then to print division of x and y (i.e. x/y)$ x=20$ y=5$ expr $x / $y Example 3: Modify above and store division of x and y to variable called z$ x=20$ y=5$ z=`expr $x / $y`$ echo $z To execute a program in Linux, type: ./filename, e.g., ./xxx ` (back quote) executes the command 9/15/15

  30. / junks primary secondary my_junk_file my_primary_file my_secondary.log Practice • Read about chmod - Read about LINUX permissions (check the hyperlink) • Find install.log file • For simple examples of scripts go to http://www.freeos.com/guides/lsst/misc.htm#commonvi • Write a shell script & using grep command (or anything else) display the IP address & machine name (use uname) • Create the following directories & files (/ is the root directory): 9/15/15

  31. Practice (cont) • Write a shell script (called myshell) to perform the following: • Remove all the new directories: junks, primary, secondary. • Backup HOSTS file by creating HOSTS_BACK • Display the IP address of your machine • Create a new file called YOUR_IP_ADDRESS containing the IP address of your machine  thus, by doing a less YOUR_IP_ADDRESS we should get your IP address • Change the permission on YOUR_IP_ADDRESS such that can only be viewed by the user & make sure it is readable only. Note: you should be able to run the script multiple times with no errors! (make sure you try running your program multiple times) 9/15/15

More Related