introduction to unix afnog x may 2009 cairo, egypt
Post on 29-Dec-2015
Embed Size (px)
Introduction to UNIXAfNOG XMay 2009Cairo, Egypt
Boot Camp Summary Time Table
Why use UNIX? Scalability and reliabilityhas been around for many yearsworks well under heavy loadFlexibilityemphasises small, interchangeable componentsManageabilityremote logins rather than GUIscriptingSecurityDue to modular design has a reasonable security modelUNIX and its applications are not blameless though
Initial topics:UNIX birds-eye overviewPartitioningFreeBSD installation
KernelThe "core" of the operating systemDevice driverscommunicate with your hardwareblock devices, character devices, network devices, pseudo devicesFilesystemsorganise block devices into files and directoriesMemory managementTimeslicing (multiprocessing)Networking stacks - esp. TCP/IPEnforces security model
ShellCommand line interface for executing programsDOS/Windows equivalent: command.com or command.exeChoice of similar but slightly different shellssh: the "Bourne Shell". Standardised in POSIXcsh: the "C Shell". Not standard but includes command historybash: the "Bourne-Again Shell". Combines POSIX standard with command history. But distributed under GPL (more restrictive than BSD licence)
User processesThe programs that you choose to runFrequently-used programs tend to have short cryptic names"ls" = list files"cp" = copy file"rm" = remove (delete) fileLots of stuff included in the base systemeditors, compilers, system admin toolsLots more stuff available to install toopackages / ports
System processesPrograms that run in the background; also known as "daemons" ==>Examples:cron: executes programs at certain times of daysyslogd: takes log messages and writes them to filesinetd: accepts incoming TCP/IP connections and starts programs for each onesshd: accepts incoming loginssendmail (other MTA daemon like Exim): accepts incoming mail
Security modelNumeric IDsuser id (uid 0 = "root", the superuser)group idsupplementary groupsMapped to names/etc/passwd, /etc/group (plain text files)/etc/pwd.db (fast indexed database)Suitable security rules enforcede.g. you cannot kill a process running as a different user, unless you are "root"
Standard PC boot sequencePower to the Computer.Basic Input/Output System (BIOS) is read from a chip.The BIOS locates a suitable boot source (e.g. hard drive, CD-ROM, network, USB).Disks are divided into 512-byte blocks.The very first block is the Master Boot Record (MBR).The BIOS loads and runs the code in the MBR, which continues the bootup sequence.
PartitioningThe MBR contains a table allowing the disk to be divided into partitions (4 max.).Beyond that, you can nominate one partition as an "extended partition" and then further subdivide it into "logical partitions".FreeBSD has its own partitioning system, because UNIX pre-dates the PC.FreeBSD recognises MBR partitions, but calls them "slices" to avoid ambiguity.
FreeBSD partitionsPartitions (usually) sit within a slice.Partitions called a,b,c,d,e,f,g,h.CANNOT use 'c'for historical reasons, partition 'c' refers to the entire sliceBy convention, 'a' is root partition and 'b' is swap partition.'swap' is optional, but used to extend capacity of your system RAM.
Simple partitioning: /dev/da0 (20GB)/ (root partition) da0s1a 512 MB swap partition da0s1b ~ 2 x RAM/var da0s1d 4-8 GB (+)/tmp da0s1e 1-2 GB/usr da0s1f rest of disk
'Auto' PartitionDuring FreeBSD installation you can choose this option. It does the following:
Small root partitionthis will contain everything not in another partition/boot for kernel, /bin, /sbin etc.A swap partition for virtual memorySmall /tmp partitionso users creating temporary files can't fill up your root partitionSmall /var partitionRest of disk is /usrHome directories are /usr/home/
Partitioning Issues/var may not be big enough/usr contains the OS, 3rd party software, and your own important dataIf you reinstall from scratch and erase /usr, you will lose your own dataSo you might want to split into /usr and /uSuggest 4-6GB for /usr, remainder for /uEverything in / is now more common due to RAID. Why? Valid?Some people use a ramdisk for /tmp# /etc/fstab: 64MB ramdiskmd /tmp mfs -s131072,rw,nosuid,nodev,noatime 0 0
Core directory refresher/ (/boot, /bin, /sbin, /etc, maybe /tmp) /var (Log files, spool, maybe user mail)/usr (Installed software and home dirs)swap (Virtual memory)/tmp (May reside under /)
Don't confuse the the root account (/root) with the root (/) partition.d
Note...Slicing/partitioning is just a logical divisionIf your hard drive dies, most likely everything will be lost.If you want data security, then you need to set up mirroring with a separate drive.Another reason to keep your data on a separate partition, e.g. /uRemember, rm -rf on a mirror works very well.Or, as always Data Security Backup
Summary: block devicesIDE (ATAPI) disk drives/dev/ad0/dev/ad1 ...etcSCSI or SCSI-like disks (e.g. USB flash, SATA)/dev/da0/dev/da1 ...etcIDE (ATAPI) CD-ROM/dev/acd0 ...etcTraditional floppy drive/dev/fd0etc.
SummarySlices (scsi/sata)/dev/da0s1/dev/da0s2/dev/da0s3/dev/da0s4Defined in MBRSlices == Partitions in the Windows universe.BSD Partitions/dev/da0s1a/dev/da0s1b/dev/da0s1d ...etc/dev/da0s2a/dev/da0s2b/dev/da0s2d ...etcConventions:'a' is /'b' is swap'c' cannot be used
Installing FreeBSDSurprisingly straightforwardBoot from CD/DVD, runs "sysinstall"Slice your diskCan delete existing slice(s)Create a FreeBSD slicePartitionChoose which parts of FreeBSD distribution you want, or choose "all"Install from choice of mediaCD-ROM, DVD, FTP/PXE boot, etc.
Finding more informationOur reference handoutman pagesUse this when you know the name of the commandwww.freebsd.orghandbook, searchable website / mail archives"The Complete FreeBSD" (O'Reilly)comp.unix.shell FAQhttp://www.faqs.org/faqs/ by-newsgroup/comp/comp.unix.shell.htmlSTFW (Search The Friendly Web), or GIYF