23
Introduction to Introduction to UNIX UNIX CMSC 121 CMSC 121 Material source based on slides from Eric Eaton. Material source based on slides from Eric Eaton.

Introduction to UNIX CMSC 121 Material source based on slides from Eric Eaton

Embed Size (px)

Citation preview

Page 1: Introduction to UNIX CMSC 121 Material source based on slides from Eric Eaton

Introduction toIntroduction toUNIXUNIX

CMSC 121CMSC 121

Material source based on slides from Eric Eaton.Material source based on slides from Eric Eaton.

Page 2: Introduction to UNIX CMSC 121 Material source based on slides from Eric Eaton

What is an Operating What is an Operating System?System?

The operating system (OS) is the program which starts The operating system (OS) is the program which starts up when you turn on your computer and runs up when you turn on your computer and runs underneath all other programs - without it nothing underneath all other programs - without it nothing would happen at all.would happen at all.

In simple terms, an operating system is a In simple terms, an operating system is a managermanager. It . It manages all the available resources on a computer, manages all the available resources on a computer, from the CPU, to memory, to hard disk accesses.from the CPU, to memory, to hard disk accesses.

Tasks the operating system must perform:Tasks the operating system must perform: Control HardwareControl Hardware - The operating system controls all the - The operating system controls all the

parts of the computer and attempts to get everything working parts of the computer and attempts to get everything working together. together.

Run ApplicationsRun Applications - Another job the OS does is run application - Another job the OS does is run application software. This would include word processors, web browsers, software. This would include word processors, web browsers, games, etc... games, etc...

Manage Data and FilesManage Data and Files - The OS makes it easy for you to - The OS makes it easy for you to organize your computer. Through the OS you are able to do a organize your computer. Through the OS you are able to do a number of things to data, including copy, move, delete, and number of things to data, including copy, move, delete, and rename it. This makes it much easier to find and organize what rename it. This makes it much easier to find and organize what you have. you have.

Page 3: Introduction to UNIX CMSC 121 Material source based on slides from Eric Eaton

UNIX HistoryUNIX History The UNIX operating system was born in the late The UNIX operating system was born in the late

1960s. It originally began as a one man project led 1960s. It originally began as a one man project led by Ken Thompson of Bell Labs, and has since grown by Ken Thompson of Bell Labs, and has since grown to become the most widely used operating system.to become the most widely used operating system.

In the time since UNIX was first developed, it has In the time since UNIX was first developed, it has gone through gone through manymany different generations and even different generations and even mutations.mutations. Some differ substantially from the original version, like Some differ substantially from the original version, like

Berkeley Software Distribution (BSD) or Linux.Berkeley Software Distribution (BSD) or Linux. Others, still contain major portions that are based on the Others, still contain major portions that are based on the

original source code.original source code. An interesting and rather up-to-date timeline of An interesting and rather up-to-date timeline of

these variations of UNIX can be found at these variations of UNIX can be found at http://www.levenez.com/unix/history.htmlhttp://www.levenez.com/unix/history.html..

Page 4: Introduction to UNIX CMSC 121 Material source based on slides from Eric Eaton

General Characteristics of General Characteristics of UNIX as an Operating UNIX as an Operating

System (OS)System (OS) Multi-user & Multi-taskingMulti-user & Multi-tasking - most versions of UNIX are capable of allowing - most versions of UNIX are capable of allowing

multiple users to log onto the system, and have each run multiple tasks. This multiple users to log onto the system, and have each run multiple tasks. This is standard for most modern OSs. is standard for most modern OSs.

Over 30 Years OldOver 30 Years Old - UNIX is over 30 years old and it's popularity and use is - UNIX is over 30 years old and it's popularity and use is still high. Over these years, many variations have spawned off and many have still high. Over these years, many variations have spawned off and many have died off, but most modern UNIX systems can be traced back to the original died off, but most modern UNIX systems can be traced back to the original versions. It has endured the test of time. For reference, Windows at best is versions. It has endured the test of time. For reference, Windows at best is half as old (Windows 1.0 was released in the mid 80s, but it was not stable or half as old (Windows 1.0 was released in the mid 80s, but it was not stable or very complete until the 3.x family, which was released in the early 90s). very complete until the 3.x family, which was released in the early 90s).

Large Number of ApplicationsLarge Number of Applications – there are an enormous amount of – there are an enormous amount of applications available for UNIX operating systems. They range from applications available for UNIX operating systems. They range from commercial applications such as CAD, Maya, WordPerfect, to many free commercial applications such as CAD, Maya, WordPerfect, to many free applications. applications.

Free Applications and Even a Free Operating SystemFree Applications and Even a Free Operating System - of all of the - of all of the applications available under UNIX, many of them are free. The compilers and applications available under UNIX, many of them are free. The compilers and interpreters that we use in most of the programming courses here at UMBC interpreters that we use in most of the programming courses here at UMBC can be downloaded free of charge. Most of the development that we do in can be downloaded free of charge. Most of the development that we do in programming courses is done under the Linux OS. programming courses is done under the Linux OS.

Less Resource IntensiveLess Resource Intensive - in general, most UNIX installations tend to be - in general, most UNIX installations tend to be much less demanding on system resources. In many cases, the old family much less demanding on system resources. In many cases, the old family computer that can barely run Windows is more than sufficient to run the computer that can barely run Windows is more than sufficient to run the latest version of Linux. latest version of Linux.

Internet DevelopmentInternet Development - Much of the backbone of the Internet is run by - Much of the backbone of the Internet is run by UNIX servers. Many of the more general web servers run UNIX with the UNIX servers. Many of the more general web servers run UNIX with the Apache web server - another free application. Apache web server - another free application.

Page 5: Introduction to UNIX CMSC 121 Material source based on slides from Eric Eaton

Parts of the UNIX OSParts of the UNIX OS The KernelThe Kernel - handles memory management, input and output - handles memory management, input and output

requests, and program scheduling. Technically speaking, the kernel requests, and program scheduling. Technically speaking, the kernel isis the OS. It provides the basic software connection to the hardware. the OS. It provides the basic software connection to the hardware. The kernel is very complex and deals with the inner workings of these The kernel is very complex and deals with the inner workings of these things, and is beyond the scope of this course. The kernel is covered things, and is beyond the scope of this course. The kernel is covered in detail in “Operating Systems.”in detail in “Operating Systems.”

The Shell and Graphical User Interfaces (GUIs) The Shell and Graphical User Interfaces (GUIs) - basic UNIX - basic UNIX shells provides a “command line” interface which allows the user to shells provides a “command line” interface which allows the user to type in commands. These commands are translated by the shell into type in commands. These commands are translated by the shell into something the kernel can comprehend, and then executed by the something the kernel can comprehend, and then executed by the kernel. kernel.

The Built-in System UtilitiesThe Built-in System Utilities - are programs that allow a user to - are programs that allow a user to perform tasks which involve complex actions. Utilities provide user perform tasks which involve complex actions. Utilities provide user interface functions that are basic to an operating system, but which interface functions that are basic to an operating system, but which are too complex to be built into the shell. Examples of utilities are are too complex to be built into the shell. Examples of utilities are programs that let us see the contents of a directory, move & copy programs that let us see the contents of a directory, move & copy files, remove files, etc... files, remove files, etc...

Application Software & UtilitiesApplication Software & Utilities – these are not part of the – these are not part of the operating system, per se. They are additional programs that are operating system, per se. They are additional programs that are bundled with the OS distribution, or available separately. These can bundled with the OS distribution, or available separately. These can range from additional or different versions of basic utilities, to full range from additional or different versions of basic utilities, to full scale commercial applications. scale commercial applications.

Page 6: Introduction to UNIX CMSC 121 Material source based on slides from Eric Eaton

Flavors of UNIXFlavors of UNIX These can be grouped into two categories:These can be grouped into two categories: Open Source Open Source and and

ProprietaryProprietary Proprietary:Proprietary: (redistribution and modification prohibited or restricted) (redistribution and modification prohibited or restricted)

SolarisSolaris - Available on solaris.gl.umbc.edu via SSH. - Available on solaris.gl.umbc.edu via SSH. Mac OS XMac OS X - Available on any Mac in computer labs. - Available on any Mac in computer labs. and many others... and many others...

Open Source: Open Source: (source code is readily available and free to modify)(source code is readily available and free to modify) OpenSolarisOpenSolaris - Solaris with the latest functionality. - Solaris with the latest functionality. Linux Distributions - Available on dual-boot PCs scattered throughout Linux Distributions - Available on dual-boot PCs scattered throughout

the Engineering building. Also available on the interactive Linux the Engineering building. Also available on the interactive Linux servers (linux.gl.umbc.edu) via SSH.servers (linux.gl.umbc.edu) via SSH.

RedHatRedHat (used by UMBC) and the (used by UMBC) and the Fedora ProjectFedora Project (maintained by (maintained by RedHat)RedHat)

UbuntuUbuntu DebianDebian SuSESuSE SlackwareSlackware and many others...and many others...

As a side note, Linux is a open source UNIX-like OS that was originally As a side note, Linux is a open source UNIX-like OS that was originally developed in 1991 by Linus Torvalds, a Finnish undergraduate student. developed in 1991 by Linus Torvalds, a Finnish undergraduate student.

Page 7: Introduction to UNIX CMSC 121 Material source based on slides from Eric Eaton

UNIX InterfacesUNIX Interfaces There are two means of connecting to There are two means of connecting to

UNIX computers here at UMBC:UNIX computers here at UMBC: You can be sitting in front of a dual-bootable PC You can be sitting in front of a dual-bootable PC

that you have booted into Linux and logged that you have booted into Linux and logged onto. All of your commands are then being run onto. All of your commands are then being run locally on that computer. When you logon in locally on that computer. When you logon in this manner you have a full GUI environment. this manner you have a full GUI environment.

You can connect remotely to one of the UNIX You can connect remotely to one of the UNIX servers (whether from home or at the labs). servers (whether from home or at the labs). This is often how your projects are suggested to This is often how your projects are suggested to be developed as they are graded on those same be developed as they are graded on those same servers. When you logon in this manner you servers. When you logon in this manner you have a command line (or text based) have a command line (or text based) environment. You can also open up a command environment. You can also open up a command line on local lab machines as well. line on local lab machines as well.

Page 8: Introduction to UNIX CMSC 121 Material source based on slides from Eric Eaton

Graphical User Graphical User Interfaces (GUIs)Interfaces (GUIs)

When you logon locally, you are presented When you logon locally, you are presented with graphical environment.with graphical environment.

You start at a graphical login screen. You You start at a graphical login screen. You must enter your username and password. You must enter your username and password. You also the have the option to choose from also the have the option to choose from several session types. The two primary several session types. The two primary choices that provide different desktop choices that provide different desktop environments are GNOME and KDE. GNOME environments are GNOME and KDE. GNOME is the recommended choice.is the recommended choice.

Once the login succeeds, you are then Once the login succeeds, you are then presented with a graphical environment.presented with a graphical environment.

Page 9: Introduction to UNIX CMSC 121 Material source based on slides from Eric Eaton

GNOMEGNOME

Page 10: Introduction to UNIX CMSC 121 Material source based on slides from Eric Eaton

KDEKDE

Page 11: Introduction to UNIX CMSC 121 Material source based on slides from Eric Eaton

Command Line InterfaceCommand Line Interface You also have access to some UNIX servers as You also have access to some UNIX servers as

well.well. You can logon from virtually any computer that has You can logon from virtually any computer that has

internet access whether it be Windows, Mac, or UNIX internet access whether it be Windows, Mac, or UNIX itself.itself.

In this case you are communicating through a In this case you are communicating through a local terminal to one of these remote servers.local terminal to one of these remote servers. All of the commands actually execute on the remote All of the commands actually execute on the remote

server.server. It is also possible to open up graphical applications It is also possible to open up graphical applications

through this window, but that requires a good bit more through this window, but that requires a good bit more setup and software. (Time permitting, we may cover setup and software. (Time permitting, we may cover how to do this.)how to do this.)

Page 12: Introduction to UNIX CMSC 121 Material source based on slides from Eric Eaton

The TerminalThe Terminal

Page 13: Introduction to UNIX CMSC 121 Material source based on slides from Eric Eaton

Linux vs. WindowsLinux vs. Windows OS does not have to use a graphical interface.OS does not have to use a graphical interface.

The OS itself (the kernel) is incredibly small. The OS itself (the kernel) is incredibly small. The GUI just another application (or set of applications) The GUI just another application (or set of applications)

that can be installed and run on top the existing text-based that can be installed and run on top the existing text-based OS. OS.

File system differences.File system differences. Windows typically uses FAT32 or NTFS file systems. Windows typically uses FAT32 or NTFS file systems. Linux typically uses the ext2 or ext3 file systems.Linux typically uses the ext2 or ext3 file systems. In much larger research and university environments, In much larger research and university environments,

where file access is necessary across the network, where file access is necessary across the network, something like Network File System (NFS) or the Andrew something like Network File System (NFS) or the Andrew File System (AFS) is used. AFS is used at UMBC. File System (AFS) is used. AFS is used at UMBC.

Windows lists all drives separately (A:,C:,D:, etc…), with Windows lists all drives separately (A:,C:,D:, etc…), with “My Computer” at the highest level.“My Computer” at the highest level.

UNIX starts its highest level at “/” (called root) and file UNIX starts its highest level at “/” (called root) and file systems can be mounted anywhere underneath it. The local systems can be mounted anywhere underneath it. The local hard disk is “/”, but the shared AFS storage is found at the hard disk is “/”, but the shared AFS storage is found at the subdirectory (this is technically called a mount point) subdirectory (this is technically called a mount point) “/afs”.“/afs”.

Page 14: Introduction to UNIX CMSC 121 Material source based on slides from Eric Eaton

UMBC’s Computing UMBC’s Computing EnvironmentEnvironment

You need a myUMBC account username and password!You need a myUMBC account username and password! Since almost all UNIX systems are multi-user systems you will Since almost all UNIX systems are multi-user systems you will

need to have a logon name and password to authenticate need to have a logon name and password to authenticate yourself to the system. At UMBC, when you signup for a yourself to the system. At UMBC, when you signup for a myUMBC account, you are given a username and password, myUMBC account, you are given a username and password, which is your means of logging on to any computer system, be which is your means of logging on to any computer system, be it UNIX, Windows or Mac.it UNIX, Windows or Mac.

Where is UNIX / Linux available?Where is UNIX / Linux available? There are many labs throghout campus where there are dual-There are many labs throghout campus where there are dual-

bootable Windows and Linux PCs. You can reboot one of these bootable Windows and Linux PCs. You can reboot one of these machines and select Linux as the operating system.machines and select Linux as the operating system.

There are also a couple of other places across the campus There are also a couple of other places across the campus where you can sit directly in front of a UNIX computer. where you can sit directly in front of a UNIX computer. UMBC's Division of Information Technology (DoIT) maintains a UMBC's Division of Information Technology (DoIT) maintains a list of the labs it maintains as well as descriptions about the list of the labs it maintains as well as descriptions about the operating systems in those labs.operating systems in those labs.

See list: See list: https://spaces.umbc.edu/display/oit2/Lab+Locationshttps://spaces.umbc.edu/display/oit2/Lab+Locations..

Page 15: Introduction to UNIX CMSC 121 Material source based on slides from Eric Eaton

Practical TasksPractical Tasks

Rebooting the computer into Linux Rebooting the computer into Linux on a dual-boot PC.on a dual-boot PC.

Logging in.Logging in. Locking the screen.Locking the screen. Logging out.Logging out. The non-graphical terminal!The non-graphical terminal!

Press Control-Alt-F2 then login.Press Control-Alt-F2 then login. Be sure to logout with the command: Be sure to logout with the command:

exitexit Press Control-Alt-F7 to get the GUI Press Control-Alt-F7 to get the GUI

back (sometimes the GUI can be found back (sometimes the GUI can be found on Control-Alt-F6 or Control-Alt-F8 on Control-Alt-F6 or Control-Alt-F8 instead).instead).

Page 16: Introduction to UNIX CMSC 121 Material source based on slides from Eric Eaton

If all else fails in Gnome If all else fails in Gnome or KDEor KDE

If your session seems to have froze If your session seems to have froze up, you can press up, you can press control-alt-control-alt-backspacebackspace to restart the X window to restart the X window server, in the process logging you server, in the process logging you out.out.

Note that by doing it this way, you Note that by doing it this way, you risk losing unsaved work.risk losing unsaved work.

Page 17: Introduction to UNIX CMSC 121 Material source based on slides from Eric Eaton

What is X Window?What is X Window? X window is the program that draws windows on the X window is the program that draws windows on the

screen under most GUI-based versions of UNIX. It is screen under most GUI-based versions of UNIX. It is important to note that the language that X windows important to note that the language that X windows speaks is completely different from that of Microsoft speaks is completely different from that of Microsoft Windows or Mac OS X.Windows or Mac OS X.

Any X window system consists of two distinct parts - the Any X window system consists of two distinct parts - the X server and one or more X clients.X server and one or more X clients. The server controls the display directly, and is responsible for The server controls the display directly, and is responsible for

all input/output via the keyboard, mouse or display.all input/output via the keyboard, mouse or display. The clients, on the other hand, do not access the screen directly The clients, on the other hand, do not access the screen directly

- they communicate with the server, which handles all input and - they communicate with the server, which handles all input and output.output.

It is the clients which do the "real" computing work - running It is the clients which do the "real" computing work - running applications or whatever. applications or whatever.

The clients communicate with the server, causing the server to open The clients communicate with the server, causing the server to open one or more windows to handle input and output for that client. one or more windows to handle input and output for that client.

Page 18: Introduction to UNIX CMSC 121 Material source based on slides from Eric Eaton

What’s the deal about the X What’s the deal about the X Window Server and Client?!Window Server and Client?!

The X window server runs on the machine to which the The X window server runs on the machine to which the monitor is connected.monitor is connected.

The clients may also run on this machine, communicating The clients may also run on this machine, communicating directly with the server. On most workstations, this is the directly with the server. On most workstations, this is the normal situation. However, X is a networked window system, normal situation. However, X is a networked window system, and it is possible for the client to run on a remote machine, and it is possible for the client to run on a remote machine, communicating with the server via some form of network.communicating with the server via some form of network.

It is possible to connect to one of the UMBC servers and It is possible to connect to one of the UMBC servers and launch graphical applications from one of the UNIX servers.launch graphical applications from one of the UNIX servers. This does require that an X window server is installed on the This does require that an X window server is installed on the

machine from which you are connecting from. This is machine from which you are connecting from. This is automatically running if you are running a GUI UNIX system.automatically running if you are running a GUI UNIX system.

You can also install an X window server on top of Microsoft You can also install an X window server on top of Microsoft Windows, so that you can open up windows locally that are Windows, so that you can open up windows locally that are talking to the server at UMBC. Options include Cygwin/X and talking to the server at UMBC. Options include Cygwin/X and Xming.Xming.

Mac OS X includes X/11 which needs to be started manually.Mac OS X includes X/11 which needs to be started manually.

Page 19: Introduction to UNIX CMSC 121 Material source based on slides from Eric Eaton

What is a Desktop What is a Desktop Manager?Manager?

Gnome and KDE are examples of desktop managers. Both Gnome and KDE are examples of desktop managers. Both of these look a lot like Microsoft Windows.of these look a lot like Microsoft Windows. They have the equivalent of a Start Menu, have an equivalent They have the equivalent of a Start Menu, have an equivalent

of Windows Explorer, and have some sort of control panel.of Windows Explorer, and have some sort of control panel. The roll of the Desktop Manager is to provide you with the The roll of the Desktop Manager is to provide you with the

ability to manage all of the details of your system that ability to manage all of the details of your system that would otherwise require you to type in a bunch of would otherwise require you to type in a bunch of commands in a terminal window. commands in a terminal window. These details include managing your files, launching These details include managing your files, launching

programs, configuring various aspects of your system, etc. programs, configuring various aspects of your system, etc. It is also worthy to note that the desktop manager is It is also worthy to note that the desktop manager is

optional. Many older systems did not have a desktop optional. Many older systems did not have a desktop manger that sat in-between the X server and the Window manger that sat in-between the X server and the Window manager.manager.

Page 20: Introduction to UNIX CMSC 121 Material source based on slides from Eric Eaton

What is a Window What is a Window Manager?Manager?

The Window Manager is a program that manages the The Window Manager is a program that manages the placement of Windows on your system. The Window placement of Windows on your system. The Window Manager makes it possible to move, resize, and minimize Manager makes it possible to move, resize, and minimize the various programs running on your computerthe various programs running on your computer

KDE handles this functionality as well, whereas Gnome KDE handles this functionality as well, whereas Gnome does not directly provide this functionality, but rather does not directly provide this functionality, but rather relies on an independent window manager to do it for us.relies on an independent window manager to do it for us.

Think of the Window Manager as the framing around the Think of the Window Manager as the framing around the windows as well as all of the associated functionality that windows as well as all of the associated functionality that they provide.they provide. For example, most all window managers can close, minimize, For example, most all window managers can close, minimize,

maximize & resize.maximize & resize. However most UNIX window managers add so much more in However most UNIX window managers add so much more in

the way of functionality. The decoration and customization of the way of functionality. The decoration and customization of these windows under UNIX tends to be much more flexible.these windows under UNIX tends to be much more flexible.

Many Window Managers also provide other functionality such Many Window Managers also provide other functionality such as shading, sticky/nonsticky, window history, and desktop and as shading, sticky/nonsticky, window history, and desktop and workspace manipulations.workspace manipulations.

Page 21: Introduction to UNIX CMSC 121 Material source based on slides from Eric Eaton

Some Notes on X window, Desktop Some Notes on X window, Desktop Managers & Window ManagersManagers & Window Managers

Most UNIX systems can be installed without Most UNIX systems can be installed without the GUI.the GUI.

The GUI is just another application that The GUI is just another application that runs on top of the operating system.runs on top of the operating system.

There are many implementations of all There are many implementations of all three of these components.three of these components. It is possible to mix and match implementation It is possible to mix and match implementation

and versions of these. and versions of these. They need not be alike and need not be all by the They need not be alike and need not be all by the

same organization.same organization. This is quite a shift in paradigm from This is quite a shift in paradigm from

Microsoft and Apple.Microsoft and Apple.

Page 22: Introduction to UNIX CMSC 121 Material source based on slides from Eric Eaton

GNOMEGNOME

Desktop – directory in your homeDesktop – directory in your home Panel – menu, launchers, tools, Panel – menu, launchers, tools,

running appsrunning apps Window Manager – metacityWindow Manager – metacity File Browser - NautilusFile Browser - Nautilus

Page 23: Introduction to UNIX CMSC 121 Material source based on slides from Eric Eaton

Programming Tools and Programming Tools and UtilitiesUtilities

Text EditorsText Editors vi/vimvi/vim pico pico emacs/xemacsemacs/xemacs

CompilersCompilers gcc - C compiler gcc - C compiler g++ - C++ compiler g++ - C++ compiler java and javac - Java java and javac - Java

Virtual Machine & Java Virtual Machine & Java compilercompiler

DebuggersDebuggers gdbgdb dddddd

IDEIDE eclipseeclipse

InterpretersInterpreters perlperl pythonpython PHP PHP

MiscellaneousMiscellaneous Web Browsing - Firefox, Web Browsing - Firefox,

SeaMonkey, Opera, LynxSeaMonkey, Opera, Lynx Instant Messenging - Instant Messenging -

Pidgin Pidgin Email – Thunderbird, Email – Thunderbird,

pinepine Office Suite - OpenOfficeOffice Suite - OpenOffice