Top Banner
06/26/22 C. Edward Chow CS4 01 Pag e 1 Linux A freely distributable version of UNIX originally developed by Linus Torvalds at Univ. Helsinki Finland Originally try to be a better minix than Minix. 10/5/91 release 0.02, can run bash and gcc. Kernel designed from scratch, with task switching code in assembly, follows by code in C. (FreeBSD ported from BSD UNIX) Use Gnu tools to develop related system code. Most Network daemons and utilities ported from BSD. Can run X Windows, TCP/IP, Emacs, mail, news,...
30
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Linux

04/10/23 C. Edward Chow

CS401

Page 1

Linux

• A freely distributable version of UNIX originally developed by Linus Torvalds at Univ. Helsinki Finland

• Originally try to be a better minix than Minix.• 10/5/91 release 0.02, can run bash and gcc.• Kernel designed from scratch, with task switching code in

assembly, follows by code in C.(FreeBSD ported from BSD UNIX)

• Use Gnu tools to develop related system code.• Most Network daemons and utilities ported from BSD.• Can run X Windows, TCP/IP, Emacs, mail, news,...

Page 2: Linux

04/10/23 C. Edward Chow

CS401

Page 2

Why Linux is so popular?

• Freeware, open design group, with source code available for Application/OS/IO/network software developers, kernel hackers, multimedia authors.

• Low cost: a few dollars (for CD) or free through Internet download for the complete programming environment, on cheap pc hardware.

• Support many different peripherals (disk drive, sound card, Ethernet card, modem, CPU).

• Users participate in a very successful coordinated document project LDP, e.g. write how-to documents.

• Used in research vessel, web server, routing device,hospital DB, US marine corp mission.

Page 3: Linux

04/10/23 C. Edward Chow

CS401

Page 3

Linux System Features• Multitasking, multi-user operating system• compatible with IEEE POSIX.1,System and BSD features.• csh, bash, pty, national/customized keyboard support using

dynamically loadable drivers, virtual console.• support various file systems, ext2,msdos, iso9660, nfs, ntfs(only

read access with required kernel modification), proc, xenix, bpfs (OS2), minix, …

• can access other file systems good for dual boot situation.• TCP/IP, Ethernet drivers, PPP, SLIP, PLIP• NFS, ftp, telnet, nntp, smtp, …• demand-paged loaded executable, paging

Page 4: Linux

04/10/23 C. Edward Chow

CS401

Page 4

Basic Commands and Utilites

• ls, awk, tr, sed, bc, …• text editor: vi, ex, pico, jove, emac• text/word processing: tex, groff, xfig, • gcc (c and c++), FORTRAN, pascal, LISP, scheme• perl, Tcl/Tk (shell like command processing for

developing simple X windows applications.)• gdb, gprof, make, imake• rcs• telnet, rloign, rsh, finger, pine, rn, tin, ping, ...

Page 5: Linux

04/10/23 C. Edward Chow

CS401

Page 5

X Window System

• Linux uses X window system for graphics display and desk top environment.

• XFree86, a port of X11R6 for 386-based UNIX.• www.xfree86.org posts more recent addition of video drivers.• support various video hardware at VGA, SVGA, XGA resolutions for

both CRT adn non-interlace LCD• Xconfigurator GUI can be used to facilitate the configuration. • xterm, xclock, xman, • GNOME and KDE desk top environments. Support multiple virtual

windows.• You can also use fvmgr which minics the desk top environment of

Microsoft window systems. • need more memory to run (8MB at least)• other commerical pkg available (Metro-X)

Page 6: Linux

04/10/23 C. Edward Chow

CS401

Page 6

Linux Web Pages, Newgroup

• www.linux.org, www.redhat.com, www.debian.org• Linux Document Project home page:

http://www.linuxdoc.org/• Hardware compatiblity web page:

http://www.linuxdoc.org/HOWTO/Hardware-HOWTO.html

• comp.os.linux.[announce, answers, setup, development system, hardware, networking,x,...

Page 7: Linux

04/10/23 C. Edward Chow

CS401

Page 7

Various Distribution of Linuxhttp://www.linux.org/dist/index.html

• developers have taken the Linux source code and created a variety of different Linux distributions that have slightly different functionality:– Installation Programs/Tools– Package Management Systems– Different ways to organize directories for include files,

libraries and configuration files.– (Graphic) Administration Tools– Port to other platforms (Alpha, Sparc)– Device/Hardware support

• Redhat 6.2, Slackware Linux 7.1.0, Debian 2.2• CD-ROM distributor: infomagic, linuxmall

Page 8: Linux

04/10/23 C. Edward Chow

CS401

Page 8

Install Linux: Step 1

• Collect info (vendor/model/version) of – hard drive (IDE, SCSI)– CD-ROM (make sure to buy one supported)– Ethernet Card (e.g., 3com, Intel, HP10/100VG AnyLAN)– Mouse (PS/2, 2buttons or 3buttons)– Video chip set (e.g., Chips and Tech. 65550 PCI)– VRAM: size (e.g., 2MB)– Monitor: resolution, horizontal/vertical frequency, pixel depth.

• Newer installation programs try to detect hardware types and choose the corresponding drivers. They are much better now.

• Check Hardware Compatible List HowTo Document.

Page 9: Linux

04/10/23 C. Edward Chow

CS401

Page 9

Install Linux: Step 2

• Give network administrator the domain names (bilbo, frodo, viva, vinci) of the new Linux PC and ask for – assigning IP address

(viva: 128.198.192.192, vinci:128.198.192.193)(bilbo: 128.198.192.182, frodo: 128.198.192.183)

– creating DNS entries in local DNS server (primary DNS server ccnuccs: 128.198.1.250; secondary DNS server 128.198.161.248; 128.198.1.117 as 3rd choice)

• Find out the IP address and net mask of the gateway of the LAN segment which connects the Linux PC. (128.198.192.1, 255.255.248.0)

• The IP address and the net mask 255.255.248.0 define the subnet address.

• Find out the IP address(es) of the DNS name server(s)

Page 10: Linux

04/10/23 C. Edward Chow

CS401

Page 10

Step 3: Disk Partitions• Partition disk you could dual boot with WinNT/2000/Win98/OS2• Create different partitions

– swap partition: virtual memory swapping (size of mem, 64MB)– root partition: to be mounted as /(root directory) 50-100M

This needs to be in the one of first two drives & under cylinder 1024– /usr partition: 200-500MB depends on packages– /home partition: user home directory– /tmp partition: for temporary files (server use a lot)– /var partition: system logs– /usr/src: for source code (linux, utilities)– /usr/local : for software not available in distribution

(those strings with yellow marks are mounting pt.)• It is much easier and flexible by just creating swap partition and the root

partition /. All system/user data share the same root partition.

Page 11: Linux

04/10/23 C. Edward Chow

CS401

Page 11

Step3a: Disk Partition • IDE drives, by convention, are given /dev/hd[L] as device names. L is

the letter assigned to disks in the system, starting with a.• For SCSI drive, related dev names are /dev/sd[L]• For management purpose, a hard drive is divided into disk partitions.

There are two types of disk partitions in a PC hard drive: primary and extended. Within an extended partitions you can have more logical partitions.

• Partitions are identified by /dev/hda[n] or /dev/sda[n] where n is the partition ID.

• Most disks allow 3 primary partitions and one extended partition.• Leave primary partition (/dev/hda1) for Win32, create an extended

partition (/dev/hda2) for Linux.Note that root partition need to be under cylinder1024

• From the extended partition, create logic partitions for each of the linux partitions (/dev/hda5-9)

Page 12: Linux

04/10/23 C. Edward Chow

CS401

Page 12

Step 3b: Relocate/Adjust Partitions

• To keep the content of the original window partition and create space for the new partition for Linux.– Use partition magic™ to relocate/adjust disk

partitions.– Use freeware fips program, available in CD’s

dosutils directory for relocate disk partition. Read documents in fipsdoc subdir.

– There is a DOS fdisk utility can be used to partition the disk.

Page 13: Linux

04/10/23 C. Edward Chow

CS401

Page 13

Step 4: Make boot and supplemental floppies

• need a formated 1.44MB 3.5” diskette (If you have PC Card interface, you need additional diskette.)

• On PC running window system, change to the cd-rom drive under MS-DOS prompt.

• cd dosutil• Type rawrite.exe• Enter ..\images\boot.img and a: for creating boot floppy.• If you use PC Card, you need a supplemental floppy. Put the

second diskette and Enter supp.img and a: for creating supplemental diskette, containing PC Card driver.

• You can also use autoboot.exe in dosutil directory to install without boot floppy, or setup machine to boot Linux from CD-ROM.

Page 14: Linux

04/10/23 C. Edward Chow

CS401

Page 14

Step 5: Starting installation

• Insert boot floppy, reboot machineor setup bios to boot from CD-ROM. (our PC is setup to boot from CD-ROM.)

• When boot: prompt appear, press enterfor GUI mode installation, or type text to start the text mode installation. GUI mode installation may not work on some hardware.

• Watch Linux kernel detects hardware devices• If cdrom is not detected, you may type• boot: linux hdc=cdrom (enter)• There will several dialog boxes to ask for info.• Use tab to switch among choices • Use arrow keys to select options within a choice.• Use enter key to confirm the choice.

Page 15: Linux

04/10/23 C. Edward Chow

CS401

Page 15

Select Installation Method, Language, Keyboard/Mouse Configuration,

installation type option

• If you use boot floppy, Select installation method: from CD-ROM, NFS, FTP, or SMB shared volume image from Win32 system.

• Select the default English as language selection, • Select the default choices as keyboard selection, • Select “custom” • In text mode, you select “install customer system” by pressing

down arrow key three times and hit tab for OK button, then hit enter to confirm.

Page 16: Linux

04/10/23 C. Edward Chow

CS401

Page 16

Step 6: Linux Disk Partition• You will then be asked to use druid or fdisk.• Select druid and presented with a list of the disk/partitions in

/dev/hda[n] or /dev/sda[n].• Click delete to delete the existing partitions.• After delete exiting partitions, Use druid to create linux swap and

root partitions and set their file system type.• Create swap partition by

– skip the mount point; enter 128 (MB) for size; select the linux swap file type; confirm the creation.

• create the root partition– Enter / as mount point; enter 2800 for size; check the “grow to

fill” option; confirm the creation of root partition. The root partition size will adjust to ~2951 MB.

• By default Linux create Linux native type (ext2 file system).

Page 17: Linux

04/10/23 C. Edward Chow

CS401

Page 17

Step6a: Suggested Disk Partitions

• We have a 3079MB Drive in each of two PCs.• First create the linux swap partition. No mount point

string is given.• Then create a linux native partition, give 2800 as size

and check the option to “Grow to fill disk”. Enter / as mount point.

• Here are suggested Disk Partitions for our exerciseMount Point Partition Size MB File Type

hda1 128 Linux swap

/ hda2 2951 Linux native

Page 18: Linux

04/10/23 C. Edward Chow

CS401

Page 18

Step 7: File System Configuration

• Choose the root partition /dev/hda1 for formatting. • If you would like to keep the data of older partitions

such those for win32, you should not choose to format them.

• If you know the disk is ok and you do not have check the “Check for bad blocks while formatting” option. It will speed up the formatting.

Page 19: Linux

04/10/23 C. Edward Chow

CS401

Page 19

Configure Loader/ Network options

• Install LILO (the LInux LOader). Select the first option: on the Master Boot Record (MBR).

• For dual boot you may want choose to install LILO on the first sector of the root partition and avoid compete with the Window NT loader on MBR. (See slide 21)

• Network Configuration: unchecked DHCP. We would like to give web server static/permanent IP address.

• Enter the IP address 128.198.192.182 for bilbo, 183 for frodo• Enter the netmask 255.255.248.0• The network address/broadcast address will be generated.• Enter bilbo or frodo as host name• Enter 128.198.192.1 as gateways. • Enter DNS info we collect at Step 2.

Page 20: Linux

04/10/23 C. Edward Chow

CS401

Page 20

Set Time Zone and Accounts

• Select “Mountain Time Zone”• Check the “Use Daylight Saving time” and “System

Clock use UTC”.• Set a root password, cs401linux, and create a user

account with your login name. • Choose “Enable MD5 passwords”, “Enable Shadow

passwords”.• Do not check the “Enable NIS” option.

Page 21: Linux

04/10/23 C. Edward Chow

CS401

Page 21

Dual Boot using NT Loader• For dual boot using NT loader, you may want choose to install LILO on

the first sector of the root partition. This avoids competing with the Window NT loader on MBR. Once MBR is overwritten by LILO. Window systems do not know where to load kernel. It is bad for future upgrade.

• Make sure you create a boot floppy, since during the first reboot, NT loader does not have any info on how to load Linux Kernel.

• Reboot with the boot floppy. • Use dd command to copy the 512B bootsect information as a file,

bootsect.lin and save it in a floppy disk.dd if=/dev/hda3 bs=512 count-=1 of=/dosc/bootsect.lin

• Reboot without boot floppy into the window system, copy bootsect.lin file from the floppy to the window boot partition such as C:\

• Edit the C:\boot.ini and add c:\bootsect.lin=“Redhat Linux 6.2” in the OS section.

• For every new Linux installation, you need do this again.

Page 22: Linux

04/10/23 C. Edward Chow

CS401

Page 22

Step 8: Select Packages

Select packages (by pressing space bar)– Click on the list of packages you need:

NFS, SMB, ftp, web, DNS, SQL, network management workstation, Development, Kernel Development, Clustering, and Utilities.

– Some packages such as the Emacs, X development, X multimedia support, require a lot of storages

Page 23: Linux

04/10/23 C. Edward Chow

CS401

Page 23

X Windows/Monitor Setup

Monitor Setup• Then you will be presented with a long list of the monitors. Choose HP

and HP D2807A Ultra VGA 1280 17-in.• The system will detect S3 Trio64 driver.• Select “Test this configuration”.• The screen will then flash a few times when prompt window asks for

“can you see the screen” select yes.• If you did not find it, choose Custom to specify the horizontal and

veritical sync range. Choose lowest frequencies that work. Too high a range value could damage monitor.

• For notebook pc, you may choose the LCD choices such as• Non-interlaced SVGA 1024x768@87Hz or XGA.• The screen will then flash a few time while the configuration program

probe you video card and suggest color depth and resolution. Choose the “use default setting”.

Page 24: Linux

04/10/23 C. Edward Chow

CS401

Page 24

Step 9: Create file system on partitions and install packages

• It will go through each partition and create ext2 file systems. (may take about 4 min.)

• Then software modules of selected packages will be shown being installed with the total #, completed #, and remaining # of software packages and their estimated times.

• There will be about 426 packages and 601MB.• It should take about 15 min to install all these packages.• You will then be asked to create boot disk. If you use NT loader

for dual boot, make sure you create one.• Make sure you remove the CD and boot disk.

Page 25: Linux

04/10/23 C. Edward Chow

CS401

Page 25

Printer Setup

• Login as root, type printtool in a terminal window.• Hit “add” button. Choose Remote Unix (lpd) Queue.• In Edit Remove Uix Queue Entry form, choose default

queue name (lp), and default spool directory• Enter harpo as remote hostname, and hplj1 as remote

queue.• Hit input Fileter select button, select postscript printer.

Choose default 300x300 resolution and letter option.• Use Test | Print postscript test page to print test page• Use lpr to print document on the laser printer in ENS149

Page 26: Linux

04/10/23 C. Edward Chow

CS401

Page 26

Running Linux• At boot: prompt, press enter (or type tab to show a list of OS’s, type

the name of OS you want to run.)• You will see the kernel got uncompressed and loaded• Detect hard drives and set up file systems.• The attached hardware will be detected/initialized.• List of network services will be started.• Login as root, enter password• Use “shutdown -h now” Don’t turn off the power until linux indicates

“system halt”. Use -r for reboot.• Enter “startx” to start X windows system• Use alt-escape for emergency exit from X windows, e.g. got stuck.• Important reference: (redhat user guide and,

– “Running Linux” by Matt Welsh and Lar Kauffman, O’reilly– “Linux Network Administrator’s Guide” by Olaf Kirch, O’reilly

Page 27: Linux

04/10/23 C. Edward Chow

CS401

Page 27

Set UP and Use Linuxconf

• As root user, type “Linuxconf” to configure network interface.• Select the basic host info and adaptor 1. • Enter bilbo.uccs.edu in Primary name+domain• Select adaptor 2, enter viva.uccs.edu with IP address 128.198.192.192

or vinci with 128.198.192.193.• Select DNS entry on the left pane.• Enter uccs.edu as default domain and search domain 1 (opt).• Select MISC-Linuxconf network access• Check enable network access and log access.• Enter 128.198.0.0 as network or host. This restricts net access.• Choose to accept and act/changes; Exit linxuconf• Test the network connection by typing “ping 128.198.1.250”.• Note that when network access is turned on. Linuxconf can be accessed

as http://bilbo.uccs.edu:98/ This allows remote system management.

Page 28: Linux

04/10/23 C. Edward Chow

CS401

Page 28

Security and Upgrade Patches

• Security advisaries (patches) and upgrade packages are available at http://www.redhat.com/support/errata/rh62-errata-security.html.

• Download those RPM packages from redhat or other mirror sites http://www.redhat.com/mirrors.html such as ftp://ftp.eecs.umich.edu/pub/linux/redhat/redhat/updates/6.2/i386/

• Save them in usr/src/redhat/RPMS• Execute rpm –Uvh *.rpm for upgrading the packages.

Page 29: Linux

04/10/23 C. Edward Chow

CS401

Page 29

Apache Web Server

• The Apache web server should be up and running!• Go to other machine with a browser and try http://bilbo/ or use

the local Netscape browser with http://localhost.• Default home page is in /home/httpd/html/index.html• All CGI programs, icons, html pages are stored in default

directory /home/httpd.• The configuration files are in /etc/httpd/conf• Log files in /var/log/httpd• You are now ready to practice the exercises in “Apache: the

definitive guide.”

Page 30: Linux

04/10/23 C. Edward Chow

CS401

Page 30

HW#2: Linux/Apache Installation• Install Rehat Linux 6.2 on Bilbo or Frodo.• Make brief note on the steps and interactions during the installation.• Choose “customize” installation instead of default server or workstation

installation.• Create swap and root partitions as suggested in the handout.• In step 8, check the specific packages: web, ftp, sql, nfs.• Edit /home/httpd/conf/httpd.conf with ServerName bilbo<frodo> and start web

server with “/usr/sbin/httpd”• Ftp your personal web page and images files to the machine.• Make a cgi-bin directory in /home/httpd/cgi-bin/<yourlogin>.• Copy ~chow/public_html/cgi-bin/chow/sessionvar.pl• Make sure all paths are readable or executable. • From the browser on other machines in the lab, make hard copies of the

default web page, your personal web page, and the result of the sessionvar.pl. Submit your brief installation note with those hard copies as your hw2.