300 likes | 309 Views
Learn about the history and evolution of Linux, from its origins in Unix to the development of the Linux kernel. Explore the features, benefits, and uses of Linux as an operating system. Discover how Linux can be used on various devices and its popularity among developers.
E N D
Department of Engineering ScienceEE 465 (CES 440) - Intro. to Networking & Network Management An Intro to Linux
It All Started With UNIX • Linux is an Operating System (OS) based on Unix. • Linux commands come mainly from Unix. • Unix was developed in 1970 by AT&T Bell Labs. • 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 BSD (Berkeley Software Distribution) Unix. • SVR4 (System V Release 4) combines all Berkeley enhancements & original features. • Unix was essentially for workstations, big computers, & servers, • e.g., Sun Microsystems Workstations Sun Microsystems, founded in 1982, created Java programming language, Solaris OS; was acquired by Oracle Corporation in 2010https://en.wikipedia.org/wiki/Sun_Microsystems
Then Came Linux • Created in 1991 by Linus Torvalds, a software developer who became the chief architect of the Linux kernel. • Released in 1994 as Version 1. • Was initially developed for 80 & x86 processors (8080, 8086, .. i386) architecture processors*. • Later for small computers & PC-based operating system. • Today it supports various processor & servers including • AMD, Motorola 6800, Power PC, etc. • Runs on embedded systems, firmware, switches, routers, mobile phones (Android), tablets, video game consoles. • Ubuntu OS is based on Linux OS, & Linux is part of Ubuntu. • Linux programming is free, easy, simple, secure, easy to install, & can be used on micro computers. 8080, 8086, and i386 are the Intel 8-, 16-, & 32-bit processors.
Linux, Layered Views http://www.tellmeaboutlinux.com/content/linux-architecture User User Application Programs Shell / Photo / WP / FTP / Telnet / Web Browser User request Application Programmer Interface (API)- C/C++/Java/Fortran Applications SHELL Operating System (Kernel) Lower Level Utilities Computer Hardware, I/O devices, Memory, CPU, Storage Devices LINUX KERNEL Utility software is a small program that configures, maintains & monitors a computer (e.g., print utility). Computer Hardware
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 • Versions offer improvements in - Support of more hardware - Higher Stability - Support of billions of users & File System - Handle of external devices & plug-ins - Supports many new devices (Wireless, USB-based, different storage devices using IDE, SCSI, ..) - Support of Sound system - Support of higher security Using SELinux (Security Enhanced Linux) IDE = Interactive Development Environment SCSI = Small Computer System Interface
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
Linux Platform • A Linux shell, also called the “Command Line“ • Provides the traditional user interface using terminal and keyboard for the Linux OS. • Contains standard commands for Unix. • Good learning tool to learn Unix! • Basic Shell applications are: • BASH (Bourne Again Shell) • BASH is similar to Bourne Shell in Unix. • Most commonly used • C Shell, tcsh (TENEX C Shell), scsh (Scheme Shell) • http://www.freebsdsoftware.org/shells/ has list of various shells & their differences. • Commands are the instructions for the computer to do certain things.
Linux Text Editors • A text editor is a type of program used for editing plain text files. • A Linux program is made of many commands & lines of code. • 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 • Text editor comes in form of Terminal Command Line Interface (CLI) or Graphic User Interface (GUI). • “vim”, an improved version of “vi” CLI. developed by Bill Joy in C programing language for Unix OS, & Linux. It uses only keyboard. • “gedit”, CLI & GUI, like Windows Notepad uses mouse & keyboard, friendly, text editor in Ubuntu, Mac OS X, & Windows.
Gedit Text Editor • Geditis similar to Windows Notepad & the default GUI text editor in the Ubuntu OS. • Can be invoked 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
Shell Prompt • Most development work is done at the shell prompt which is the Command-Line Interface, e.g., $. • Remember root is “/” • ls – list files • ls /Documents - lists the files in Folder Documents • cd – change directory • cd /home - go to folder home • mkdir – create a directory • Mkdir homework to make a folder homework • Exercise: How can you go to CLI in: • Windows • Mac
Shell Prompt • rmdir – remove a directory • rmdir /Documents (Documents is different than documents) • 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 • vim <filename> - start editing a file • vi homework1
More 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!
Finding/Displaying Files, Patterns • grep searches file(s) for words/lines that match a given pattern grep word? filename(? For any word1, word2, word. ) • grep command can display the IP address & machine name • find searches for files that meet a desired criteria find xyz? (? For any xyz1, xyz2, xyz. ) • cat concatenates file & prints on the standard output cat xyz • echo displays message on screen echo hello
Exercise • Open shell terminal on Ubuntu • 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) Command + Options + Arguments
Linux Permissions • Permissions are set for user, group, & others • Each permission is set with a single decimal 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
Linux Script Example 1 Scriptis a collection of commands typed in text, stored in a file, read by processor & executed for result. One can use a text editor (e.g., vi or gedit) to make the file. Note: “$” is the Shell prompt & “#” indicates comments. Both need a space. Example 1: Write a Linux script to print sum of two numbers, let's say 6 & 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 & op2 are any Integer Number (Number without decimal point) & 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 # expr Evaluate expressions Now It will print sum as 9, But$ expr 6+3will not work because space is required between number & operator (See Shell Arithmetic).
Linux Script Example 2 & 3 Notes: • $ with a space char after is the Linux prompt here • $ with NO space after defines a Linux variable Example 2: Define two variables x=20, y=5andthen print division of xandy (i.e. x/y).$ x=20$ y=5$ expr $x / $y Example 3: Modify aboveandstore division of xandy to variable called z.$ x=20$ y=5$ z=`expr $x / $y`$ echo $z To execute a program in Linux, type: ./filename, e.g., ./program1 ` (back quote) executes the command
/ junks primary secondary my_junk_file my_primary_file my_secondary.log Practice • Read about chmod and LINUX permissions (check the hyperlink) • For simple examples of scripts go to http://www.freeos.com/guides/lsst/misc.htm#commonvi • Create the following directories & files (/ is the root directory):
References • Slides “Iinux”, Dr. Farid Farahmand, Fall 2014 • https://www.youtube.com/watch?v=IVquJh3DXUA&t=83s • http://en.wikipedia.org/wiki/Linux • 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.freeos.com/guides/lsst/misc.htm#commonvi • http://www.freebsdsoftware.org/shells/
Linux Distribution (Linux Distros) • Each distribution is a package including the OS & different applications. • Different distributions 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 distribution 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 distribution can be through ready made packages on the net or buying the CD or just compiling a version. * https://www.tecmint.com/top-best-linux-distributions-2016/
Linux Distribution - 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 exact UNIX code.
Basic Security In Linux • Without SELinux (Security Enhanced Linux) • Domains are divided into Users & Group IDs. • The ROOT has absolute control – need to logon as “root”. • With SELinux • Domains are divided into Subjects & Objects. • Even with Super-user privilege access to some files & devices maybe denied.
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 client. • Was developed at MIT & some computer companies (X.org). • Uses mouse & keyboard. • How the actual interface looks or feels depends on the GUI interface.
Ubuntu on Windows, Multi-OS Environment • Three ways to install Ubuntu/Linux OS on your PC or laptop with Windows 7 (or above) 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 OSes 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 PCs in Salazar 2006 Windows Linux
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, used by those who know C programing language Basically most Shell types work 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.
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 • 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! To make sure, run your program multiple times.