Unix Administration 2


Published on


Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Verify the version number of tcpdump and elm for Mandrake 8.0 Check to make sure vim is actually a package on the system
  • Verify that the SSH link runs Maybe there’s a better piece of software to run?
  • 1. Maybe put in a link to some security/patch pages.
  • 1. Check Kernel version and update
  • Unix Administration 2

    1. 1. ITI-481: Unix Administration Meeting 2 Rutgers University Center for Applied Computer Technologies Chris Uriarte, Instructor
    2. 2. Today’s Agenda <ul><li>Software Installation </li></ul><ul><li>Booting and Shutting Down </li></ul><ul><li>Emergency Boot Procedures </li></ul>
    3. 3. Software Installation <ul><li>Methods of Installation </li></ul><ul><ul><li>Binary distributions </li></ul></ul><ul><ul><li>Red Hat Package Manager (RPM) </li></ul></ul><ul><ul><li>Compiling from source </li></ul></ul><ul><li>Software installations usually must be done as root. </li></ul>
    4. 4. Red Hat Package Manager (RPM) <ul><li>Generally used for installation and removal of precompiled software. </li></ul><ul><li>Originally deployed on Linux systems, now available on other major platforms (most notably, Solaris) </li></ul><ul><li>Installation of operating system and additional software on many UNIX distributions managed through RPMs. </li></ul><ul><li>RPMs that are part of the Linux Distribution can be found on your install CD at: /mnt/cdrom/<Distribution Name>/RPMS </li></ul><ul><li>RPM installations are usually managed by the rpm command (/bin/rpm) </li></ul><ul><li>As close to “setup” as you can get on UNIX – one command installs an entire software package. </li></ul>
    5. 5. RPM at the Command Line <ul><li>For a list of packages already installed: rpm –qa </li></ul><ul><li>To install a new package: rpm –ivh package-file-name </li></ul><ul><li>To upgrade an existing package: rpm –Uvh package-file-name </li></ul><ul><li>To uninstall a package: rpm –e package-name </li></ul><ul><ul><li>(package name as seen in “rpm –qa”) </li></ul></ul>
    6. 6. RPM at the Command Line (con’t) <ul><li>List the files associated with a particular package: </li></ul><ul><ul><li>rpm –ql package-name </li></ul></ul>
    7. 7. Package Files vs. Installed Packages <ul><li>An rpm package file is a file that contains all the software associated with a particular application. It ends with the .rpm extension, for example netscape-communicator-4.71-i586.rpm </li></ul><ul><li>When the package is installed, using the rpm –i option, the package name is officially entered in the system package database as the application name and version, i.e. netscape-communicator-4.71 . Therefore, to remove the package, you need use the package name – not the full name of the file that you used to install the package. </li></ul>
    8. 8. Exercise: Using Red Hat Package Manager <ul><li>Place your Linux CD in your drive - the files on your CD can now be accessed via the directory /mnt/cdrom. </li></ul><ul><li>The Mandrake/RPMS directory on your CDROM contains many RPM files. </li></ul><ul><li>Install tcpdump off of the Red Hat CD: > cd /mnt/cdrom/Mandrake/RPMS > rpm –ivh tcpdump-3.6.1-1mdk.i586.rpm </li></ul><ul><li>Uninstall elm software : > rpm -e elm-2.5.3-7mdk </li></ul><ul><li>Question: Is vim installed on your system? If so, what is the version number? </li></ul>
    9. 9. Installing Software from Source <ul><li>A source installation takes raw computer code and compiles it into a usable software program. </li></ul><ul><li>Optimizes software for platform on which it is compiled. </li></ul><ul><li>Generally provides more installation and configuration options that using a binary or RPM distribution. </li></ul><ul><li>Requires a C compiler ( gcc is the most common and is pre-installed with many systems). </li></ul>
    10. 10. Typical Steps for Installing from Source <ul><li>Download source archive. </li></ul><ul><li>Unpack archive </li></ul><ul><ul><li>filename.tar.gz or filename.tgz - use gzip and/or tar </li></ul></ul><ul><ul><li>filename.Z – use uncompress </li></ul></ul><ul><ul><li>filename.zip – use unzip </li></ul></ul><ul><li>Look at README and/or INSTALL documents for specific installation steps. </li></ul><ul><li>Usually, you: </li></ul><ul><ul><li>Run configure script if there is one. </li></ul></ul><ul><ul><li>Run make . </li></ul></ul><ul><ul><li>Run make install . </li></ul></ul><ul><li>Key: READ the README and INSTALL files! </li></ul>
    11. 11. Exercise: Installing ssh1 from Source <ul><li>Download ssh1.2.27 . Additional download locations can be found at http://www.ssh.com/products/ssh/download.html . </li></ul><ul><li>From the download directory: > tar -xvzf ssh-1.2.27.tar.gz > cd ssh-1.2.27 >./configure > make > make install </li></ul>
    12. 12. Where to Find UNIX Software <ul><li>Tucows Linux http://www.linuxberg.com </li></ul><ul><li>Freshmeat http://www.freshmeat.net/ </li></ul><ul><li>Rpmfind.net http://rpmfind.net/linux/RPM/ </li></ul><ul><li>Updates for packages distributed with Red Hat Linux can be found at any of the Red Hat Mirrors: http://www. redhat .com/download/mirror.html </li></ul>
    13. 13. Where to Find UNIX Software <ul><li>TwoCows – http://www.twocows.com </li></ul><ul><li>SunFreeware – http://www.sunfreeware.com . </li></ul><ul><li>Download.com – http://www.download.com </li></ul>
    14. 14. When will you use these software installation procedures? <ul><li>When you want to install a new system or user application. </li></ul><ul><li>When you need to apply patches, fixes or updates that have been provided by your OS vendor. </li></ul><ul><ul><li>i.e. RedHat security patches and bug fixes available at: http://www. redhat .com/apps/support/errata/ </li></ul></ul>
    15. 15. The UNIX Boot Process <ul><li>The UNIX boot process is unique. </li></ul><ul><li>UNIX is divided into system states called “run levels”, ranging from level 0 to level 6. </li></ul><ul><li>UNIX Flavors boot differently, but the general concepts are always the same: </li></ul><ul><ul><li>Bootstrap the system using a bootloader </li></ul></ul><ul><ul><li>Load the “kernel” into memory </li></ul></ul><ul><ul><li>Execute “rc scripts” (startup scripts) </li></ul></ul>
    16. 16. The Linux Boot Process <ul><li>LILO starts and Linux is selected as the operating system to boot. </li></ul><ul><li>The Linux kernel is loaded into memory and then probes system hardware. </li></ul><ul><li>The init process reads /etc/inittab and determines whether runlevel 0-6 should be started. </li></ul><ul><li>rc scripts are executed for the specified run level to start various services. </li></ul>
    17. 17. Linux Loader (LILO) <ul><li>LILO is a boot manager. </li></ul><ul><li>Usually installed in the Master Boot Record (MBR – a special segment of your hard disk that the system reads during startup). </li></ul><ul><li>Configuration file is /etc/lilo.conf . If any changes are made to lilo.conf , /sbin/lilo needs to be run for the changes to become active. </li></ul><ul><li>For Linux, LILO’s purpose is to identify the location of the kernel, which is actually just a file like: /boot/vmlinuz-2.2.12-20 </li></ul>
    18. 18. General UNIX System Booting <ul><li>Linux is unique, as it uses LILO - a very interactive bootloading system. </li></ul><ul><li>Administrators rarely interact with the bootloader on other flavors of UNIX (unless a special bootloader is present). </li></ul><ul><li>Other UNIX flavors, however, have capabilities that are similar to those of LILO. </li></ul>
    19. 19. The UNIX init Process <ul><li>init reads /etc/inittab , which designates what runlevel to start. A runlevel of initdefault is selected unless otherwise designated. </li></ul><ul><li>A runlevel determines what functionality the system should be providing. Run levels include: 0 Halt the system 1 Single-user (no networking) 2 Multiuser without NFS 3 Multiuser with NFS 4 Unused 5 Same as 3 but with X11 console 6 Reboot the system </li></ul>
    20. 20. UNIX Run Levels <ul><li>Run Level 1 – “single user mode” </li></ul><ul><ul><li>No prompts for username/password </li></ul></ul><ul><ul><li>Access only via console – no remote access to the system (i.e. telnet) </li></ul></ul><ul><ul><li>Very minimal services are running – no networking, no X Windows. </li></ul></ul><ul><ul><li>Console user has “root” permissions </li></ul></ul><ul><ul><li>User for system maintenance </li></ul></ul><ul><ul><li>Used when you forget your root password </li></ul></ul>
    21. 21. UNIX Run Levels (con’t) <ul><li>Run Level 2 </li></ul><ul><ul><li>All typical services are started </li></ul></ul><ul><ul><li>Multi-user mode – users are allowed to log into the system </li></ul></ul><ul><ul><li>NO NFS (Network File System) file sharing </li></ul></ul><ul><li>Run Level 3 </li></ul><ul><ul><li>Same as run level 2, but NFS is enabled. </li></ul></ul><ul><ul><li>***This is the DEFAULT system run level. </li></ul></ul>
    22. 22. UNIX Run Levels (con’t) <ul><li>Run Level 4 </li></ul><ul><ul><li>Not used (historical) </li></ul></ul><ul><li>Run Level 5 </li></ul><ul><ul><li>Same as run level 3, but the system will automatically boot into X Windows and console users will authenticate via an X Windows username/password interface. </li></ul></ul>
    23. 23. Special Run Levels <ul><li>Run Level 0 </li></ul><ul><ul><li>The system “halt” or “shutdown” run level </li></ul></ul><ul><ul><li>System processes are stopped and the system halts </li></ul></ul><ul><li>Run Level 6 </li></ul><ul><ul><li>The system “reboot” run level. </li></ul></ul><ul><ul><li>System processes are stopped and the machine is restarted. </li></ul></ul>
    24. 24. rc Scripts <ul><li>Run level scripts are located in /etc/rc.d/rcX.d (X=runlevel #, e.g. /etc/rc.d/rc3.d for run level 3). They are used for both startup and shutdown purposes. </li></ul><ul><li>These directories have startup scripts that run processes and applications during boot time. The scripts use the following naming convention: </li></ul><ul><ul><li>K or S + Number + Service Name (i.e. S80sendmail ) </li></ul></ul><ul><ul><li>S is for start. K is for kill. Lower numbers start before higher. </li></ul></ul><ul><li>Startup scripts take two options: start or stop . Scripts with a S are run with start option. Scripts with a K are run with a stop option. </li></ul>
    25. 25. rc scripts, con’t <ul><li>The scripts in the rcX.d directories are typically NOT actual files themselves – they are usually symbolic links to links to scripts located in /etc/rc.d/init.d or /etc/init.d </li></ul><ul><li>For example: </li></ul><ul><ul><li>A script that starts the apache server, might exist: /etc/rc.d/init.d/apache. This script need only contain the commands that required to start apache. </li></ul></ul><ul><ul><li>To start Apache during run level 3, create a symbolic link in /etc/rc.d/rc3.d called, for example, S99apache and link it to /etc/rc.d/init.d/apache </li></ul></ul>
    26. 26. rc script example <ul><li>Example – you create a script that checks the system for “world writeable” files (files that anyone on the system can write to) and emails these files to you. </li></ul><ul><li>This script is called checkworldread and is located in /etc/rc.d/init.d . </li></ul><ul><li>You would like to run this script when the system starts in ANY multiuser mode (I.e. run level 2, 3 and 5) </li></ul><ul><li>Therefore, you must create rc-style symbolic links to /etc/rc.d/init.d/checkworldread from the /etc/rc.d/rc2.d, rc3.d and rc5.d directories. </li></ul>
    27. 27. rc script diagram /etc/rc.d/rc2.d /etc/rc.d/rc3.d /etc/rc.d/rc5.d /etc/rc.d/rc1.d S99checkwr S99checkwr S99checkwr /etc/rc.d/init.d checkworldread Symbolic link
    28. 28. Ways of Changing Run Levels <ul><li>/sbin/telinit [0-6] or /sbin/init [0-6] </li></ul><ul><ul><li>Allows you to specify a specific run level to change to </li></ul></ul><ul><li>/sbin/shutdown (typically, “ shutdown now ”) </li></ul><ul><li>/sbin/reboot </li></ul><ul><li>/sbin/halt </li></ul><ul><li>At LILO boot prompt type linux <run level> (i.e. ‘linux 5’) </li></ul><ul><li>CTRL-ALT-DELETE </li></ul><ul><ul><li>Key combination on PC-based UNIX systems reboots the system Can be disabled in /etc/inittab. </li></ul></ul><ul><li>***Only power-cycle a UNIX system as a last resort. </li></ul>
    29. 29. Changing the Default Run Level <ul><li>To change the default run level, edit /etc/inittab – look for the line: </li></ul><ul><ul><li>id:3:initdefault: </li></ul></ul><ul><li>After “id:” put the run level number you wish to use as your default run level. (usually 3 and 5 are most common options) </li></ul><ul><li>Now when your machine boots, it will automatically enter that run level. </li></ul><ul><li>The default UNIX run level is 3, unless you’ve specified otherwise during setup. </li></ul>
    30. 30. Useful Keyboard Shortcuts <ul><li>Change to text console CTRL-ALT-[F1-F6] </li></ul><ul><li>Change to X-Windows CTRL-ALT-F7 </li></ul><ul><li>Terminate X-Session CTRL-ALT-Backspace </li></ul>
    31. 31. Exercise: Changing Runlevels <ul><li>As root, type the following: shutdown –t 30 –h “System Downtime Beginning” </li></ul><ul><li>Hit the power switch on your machine to turn the system back on after the shutdown process is complete. NEVER turn power off without a proper shutdown. </li></ul><ul><li>At the LILO prompt, enter “ linux 1 .” (Linux only) </li></ul><ul><li>After booting into single-user mode, type: init 5 </li></ul>
    32. 32. Emergency Boot Procedures <ul><li>If system is unable to boot normally or you forgot your root password, the following options are available: </li></ul><ul><ul><li>Boot off of your system-specific boot disk – </li></ul></ul><ul><ul><ul><li>Can be created usually be created during a UNIX install process. Linux also has a “mkbootdisk” command. </li></ul></ul></ul><ul><ul><li>Boot off of your install floppy or cdrom. You may be prompted to boot into single user mode or into a “recovery mode” </li></ul></ul><ul><ul><li>Boot into single user mode. </li></ul></ul>
    33. 33. Homework <ul><li>Reading Linux Administration: A Beginner’s Guide – assigned in class. </li></ul>