Chapter 1 Introduction to Linux 1.1 Linux Overview 1.2 Linux Distributions 1.3 Linux Kernel 1.4 Linux Shell 1.5 System Administrator 1.6 Examples and Lab Practice 1.7 Summary 1.8 Self-Review Questions 1.9 Exercises Objectives of this Chapter Introduce concepts of Linux operating system Discuss the responsibilities of a system administrator Demonstrate the Fedora Linux installation Demonstrate adding users and groups 1.1 Linux Overview Linux is a freely distributed, multitasking, multi-user UNIX like operating system. It was designed specifically for the PC. Linux distributions are available in 32-bit and 64-bit versions on a variety of platforms such as Intel, Alpha, Sparc, and Power-PC. We say Linux is UNIX like rather than saying that it is UNIX because its kernel behaves like UNIX but no UNIX code was used in the development of Linux due to the AT&T UNIX trademark. Linux has all the features of UNIX, as well as some new features. The first version on Linux was developed in 1991 by a Finish college student, Linus Torvalds. He published his project on USENET. In 1992 the software was released using the GNU (GNU’s Not Unix) General Public License (GPL), a royalty free method ot distribute software. The Free Software Foundation (FSF) was founded in 1985 and supported the development of many GNU utilities and tools for programmers and developers. Much of the GNU software was later ported and compiled into Linux. Most Linux distributions rely heavily on these GNU tools and utilities. Originally Linux was a command-line operating system without a Graphical User Interface (GUI) . In order to compete with Windows and make Linux more attractive, GNOME( GNU Network Object Model Environment) project, which is part of the GNU project was developed to provide user friendly Windows like interface. GNOME’s original intention was to create a distributed object framework similar to Microsoft’s OLE but actually the GNOME project provides two things: the GNOME desktop environment, an intuitive and attractive desktop for users; and the GNOME development platform, an extensive framework for building applications that integrate to become a complete Linux desktop GUI environment. A different free graphical desktop environment, the K Desktop Environment (KDE) was developed by the KDE project for UNIX workstations. Both GNOME and KDE are widely adopted by many Linux distributions. Learning system administration requires interacting with an operating system. It might seem desirable to provide students with experience working on all the operating systems they might use later. However, this is not possible, because new operating systems continue to be developed. Even if no new operating systems were developed there are already too many operating systems to be described in a single book. This book will use Linux to illustrate system administration concepts throughout. Linux was selected because it is open source and it can run on inexpensive PCs. Linux distributions are available that can run directly off a CD or USB device without using a dedicated partition on a hard drive. Because of the similarity of Linux to UNIX, system administration is similar in both operating systems. However, a variety of flavors of UNIX and Linux are available. Some of the common UNIX flavors include AIX, FreeBSD, HP-UX, Solaris, and Tru64. Linux flavors or distributions are described in the next section. System administration principles are the same in all the distributions, but different distributions supply different system administration tools. If you master Linux/UNIX administration well, you will not find it difficult to administer other operating systems, such as Windows. In Windows the commands are very similar to the commands in UNIX - sometimes even having the same names. The Linux market is expanding, particularly as a server operating system. International Data Corporation (IDC) reports that during the first quarter of 2008, Windows accounted for 39.2 % of all server sales revenue, UNIX for 30.6%, and Linux for 13.6%. Desktop adoption of Linux still lags with only about 1% of the market being Linux and Microsoft Windows dominating with more than 90% of the market. It is clear that, currently, Linux is primarily used for server operating system. What are some advantages of using a graphical or GUI interface? Active Thinking What are some advantage of using a command-line interface? ? 1.2 Linux Distributions A Linux distribution is a complete operating system consisting of a kernel (the core of an operating system) and utilities (tools for the operating system) together with a variety of system applications. A free distribution is supported by its open source project. An example of this is Fedora project’s support of Fedora. A commercial distribution is sponsored by a vendor. An example of a commercial sponsorship is Novell’s sponsorship of SUSE. A wide variety of open source and commercial distributions have been created. The large number of distributions often confuses beginners who are unsure how to select between the different distributions. A system administrator not only needs to know about different distributions in order to select one appropriate for a particular situation, but also to take advantages of the features of the selected distribution. Table 1.1 compares some of the popular Linux distributions. Distribution Open Source Red Hat Platform RPM Root Live CD/ DVD GUI Market Share All √ Linux √ good 60% Red Hat √ good Fedora √ All √ Debian SUSE Mandrake √ All All Intel, Power PC Intel All Dpkg Server/ Desktop Enterprise /Server include Server above √ Slackware √ Knoppix √ YaST Slackware 3rd R/H, party Debian Poor Dpm √ eval √ Unix Std Slackware, √ Debian best good good 15% 3% <3% weak <3% weak <3% Sever Server/Desktop Server/Desktop Server Desktop Table 1.1 Summary of Popular Linux Distributions Each Linux distribution listed in Table 1.1 has advantages and disadvantages. You should select a Linux distribution based on your needs. Many factors should be considered, such as: whether the system will be used for business, home use, or academic education; whether for the system will host Web applications; whether you want to have a free open source system or need to have full technical support available from the vendors; whether the prospective system administrator is a newly graduated junior IT professional or a senior administrator who prefers command-line admin style. Once you have determined your operating system needs, you can identify which Linux distributions have the features you need. For example, The Knoppix Linux distribution is available in a Live CD format so it can be used in an academic environment without a dedicated partition available to install Linux on. The Slackware Linux lacks GUI desktop supports, but has excellent support for most UNIX traditions. SUSE is popular in Europe but is not as popular as other Linux distributions in United States even though it is free. Red Hat Linux was first released in 1994 and quickly became the leading Linux distribution. It was the first Linux distribution to use RPM as its packaging format. RPM (originally Red Hat Package Manager, abbreviated RPM) is a package management system developed by Red Hat. An RPM file (package) is a way to distribute software so that the software can be easily installed, upgraded, queried, and organized. It is one of the most important features for Red Hat Linux. Red Hat discontinued the Red Hat Linux line in favor of Red Hat Enterprise Linux (RHEL) for enterprise environments. The source code of RHEL is still free, and has been the basis for several other RHEL clones, such as Fedora which is developed by the community-supported Fedora Project and sponsored by Red Hat. Fedora is an RPM-based, general purpose Linux distribution, developed by the community-supported and sponsored by Red Hat. Its first release was in 2004 when Red Hat Linux was discontinued and replaced by RHEL. Fedora's main objective is to provide free open source software, and continue to be on the leading edge of Linux technologies. Many people still refer to Fedora as Red Hat Linux. Among the many Linux distributions, the authors chose Fedora distribution to explore the Linux system administration. Fedora was selected because of its popularity in the Linux market, its free cost, its popular RPM software package management, its GNU and GNOME GUI supports, easy installation, configuration, and maintenance, and its SELinux based security features. Which Linux distribution has the largest marketshare? Active Thinking ? 1.3 Linux Kernel The kernel is the heart of the Linux operating system just like any other UNIX systems. The Linux kernel has three layers as shown in Figure 1.2. At the base of the kernel, the low level layer consists of hardware device drivers and file system drivers. The middle layer consists of process management, memory management, network management, file system management, and various other management modules. The upper layer provides a system call interface to Bash shell and other system program calls. The core of the kernel operations is found in the middle layer. Memory management makes maximum use of the limited amount of memory installed on a machine by assigning memory areas and swap space to accommodate multiple concurrent system programs. Process management is another important part of the kernel which creates processes and implements multitasking by switching the CPU between multiple processes. The kernel also keeps track of files on the disk via file system management. The network management of kernel takes cares of packet handling and communication. The Kernel runs your Linux and manages all system resources to support system programs to access system hardware. It provides all the tools with which the services can be built. These tools are accessed via the system call interface. It prevents users from accessing the hardware directly. At the lowest level, the kernel contains a hardware device driver for each kind of common hardware such as hard disk and network devices it supports. Laid on top of the Linux kernel are various services. Without these services the kernel is useless to users. User applications rely on services to request the kernel to perform tasks on behalf of the user. The services are written to take advantage of the system call interface provided by the kernel. This system allows users to perform a wide variety of activities on the computer. For instance, issue commands at the Linux command line to manipulate file system to mount new drives, start the httpd daemon on Linux for the Apache web server, run shell scripts to automate the system administration task, or run OpenOffice to type a letter. The Linux kernel space is divided into three layers. What are the Active Thinking three layers? ? Applications GNOME, KDE, Toolkits Services Apache, MySQL X windows BASH shell and Linux Utility Linux Daemons System call interface --------------------------------------------------------------------------Kernel Memory, Network, Task schedule, File System, others Management modules File system drivers, TCP/IP network drivers Figure 1.2 Linux Structure 1.4 Linux BASH Shell There are two ways for a system administrator to perform administrative tasks: by Shell command lines or by using a GUI interface. This chapter will briefly discuss the Shell command lines interface. Future chapters will explain the command line interface in greater depth and explain how to use the GNOME GUI interface. The command line interface is the most direct way to interact with a Linux system. All GUI tools for system administrations are based on these shell command lines. It is important that junior system administrators understand how to use shell command lines because it help them learn how the Linux system works. Most proficient system administrators prefer command line or shell scripts for system administration jobs. Of course, the GUI interface is more user friendly. In Figure 1.2 we can see that the Shell is on the top of the Linux kernel. Shell commands use the system call interface to interact with the kernel on behalf of a user. The most common Linux shell is called "BASH". The name comes from "Bourne Again Shell”. Bourne refers to Stephen Bourne of Bell Labs. In Linux, users can use many different shells, such as Korn shell, C shell, Bourne shell, etc. Users can switch from one shell to another shell by typing the shell name they want to switch to at the command line prompt. The Bash shell is the default shell for Linux. 1.4.1 Some Server Shell Commands Later chapters will provide more details on shell programming. This chapter will only present a very brief overview. You can use shell commands just by typing the command at the shell prompt or by writing a shell script containing one or more shell commands. In the command mode, the user types a single command (or a short sequence of commands separated by ; or | pipe separators ) and the result is displayed. Using shell scripting a user can automate a complex job. He or she edits a script text file just like the autoexec.bat file in DOS, then executes the text file as a shell batch script. Listed below are a few examples of commands in Linux. 1) File system and disk management The df command reports the amount of free space on each partition. The du command summarizes the size of a given directory and all sub-directories. The quota commands displays users' disk usage and limits. The mount command gets a list of all the mounted file systems on the system and also is used to mount a partition or device into a file system. Use umount to unmount a file or directory or device from system. In Linux, all devices, directories, and files are considered to be files. The yum command is used to install software on the server 2) Check processes running on the server The ps command checks the process running on the server and lists all the running processes with their respective process ID. The top command checks the load on the server and lists their owners, process IDs, plus total processes, sleeping processes, zombie processes, etc. The uptime command reports the basic information about the uptime and load of the server. The kill command kills a specified running process with its ID on the server. 3) Networking connection commands The ifconfig command simply gets information about network interface configuration or changes configuration. The ping command tests the connection with a specified IP address on the network. The netstat command finds the number of connections to the server via ports. The APF or CSF firewall commands can block a particular IP from connecting to the server. The nmap command can scan and discover passive services on a network to secure the system. The help system in Linux can be accessed by typing man at the prompt. The man command provides you access to an online Linux manual. If you are unsure of how to use a Linux command type man followed by the command you would like explained. For example, the following $ man ipconfig can be used to explain the ipconfig command. The various options that can be used with a command will be listed as well as an explanation of how the options are used. The above list are just a few examples. These commands and a number of others will be discussed in later chapters. 1.4.2 Shell Script Basics A shell script is a plain-text file with a .sh extension (just a convention) that contains shell commands. You can execute the script by typing its filename at the shell prompt, or by placing its name in another shell script. Below is a very simple script: echo "Hello, World!." who The who command shows all the users who are currently logged on. If you typed this script in a file and ran it, the script would show “Hello, World!” followed by list of users who are currently logged in. Most real-world scripts are more complex than this, use many system variables, and include if-then-else or looping flow controls. Such scripts will be discussed in later chapters. The BASH acronym stands for what? Active Thinking ? 1.5 System Administrator System administration covers all tasks that are necessary to keep a system (or server) up and running. The system administrator is the professional person in charge of system administration to maintain and operate the system and network. In most cases, the system administrator belongs to the IT department and reports to the CIO or director of the IT department. The system administrator is one of the most important persons in the IT department. He or she has the highest special privileges (root privilege) and duties. The system administrator needs technical knowledge of operating systems, networks, hardware, web, database, and other popular application packages. This person should know the business nature of the organization, know how to manage staff team and manage project including the equipment acquisitions. The system administrator must know how to diagnose, troubleshoot and quickly fix problems. The duties of a system administrator are wide-ranging, and vary widely from one organization to another. The system administrator is charged with installing, configuring, maintaining, securing, and providing technical support for servers. He or she must plan for and respond to service outages, document policy and procedure, and handle legal issues or any other issues that arise concerning the system servers. The system administrator must have people skills to effectively communicate with users, in addition to the technical skills necessary to deal with hardware and software problems. Technical writing skills are often a challenge, since they must document the system for users who often lack the technical expertise possessed by the administrator. Since the system administrator has great responsibility, it is important that an administrator adhere to the highest ethical standards of conduct at all times. System administrators must enforce the policy and rules written in the policy documents of the organization. Although the system administrator is not a programmer he/she still needs a good understanding of programming such as scripting for administrative task automation. In some companies, the system administrator can also be a database administrator (DBA) who maintains a database system, and is responsible for the integrity of the data plus the efficiency and performance of the system. He or she may also be the web administrator who maintains web server services (such as Apache) that allow for internal or external access to web sites. Figure 1.3 shows the environment surrounding the system administrator. The next four sub-sections discuss these four aspects. System Software daily operation, Installation, configuration, maintenance, network, security, trouble shoot, others Installation, upgrade Web server, db server, Others System admin Users Communication, tech support, training Documentations Plan, Policy, procedure, Legal, others Figure 1.3 Responsibilities of the system administrator 1.5.1 System operations 1) Day-to-day system operations The daily administrative job includes resource usage and performance (CPU, memory, disk, server load) monitoring, troubleshooting, task automation and automatic scheduling, configuration of the servers and applications, user account management and user process monitoring, and security checking. Most of the routine administrative jobs should be automated by scripting and scheduling. 2) Other common administrative tasks Some system tasks may not need to be performed on a daily basis, but are still important to keeping systems running. These include: Install, configure, support and maintain the hardware, peripherals, and network Manage, schedule, implement, maintain and test operating system upgrades, including new release upgrades and patches in accordance with established IT policies and procedures Ensure data/media recoverability by implementing a schedule of system backups Plan, evaluate, purchase hardware equipment Develop and promote standard operating procedures and enforce the policies Manage Helpdesk problem tickets and respond to users with assistance or resolution. Conducts routine hardware audits of servers and other assets Establish Disaster Recovery strategies (Planning and implementation) that include 24 x 7 on call duties to respond to service outages and problems in case of emergencies 1.5.2 Software A system administrator is responsible for maintaining the software installed on servers and sometimes on client machines as well. The system administrator’s responsibilities related to software are listed below. Note that this list does not include writing or developing new software packages. A system administrator may need to do some systems programming, but he or she should not be doing application programming. Install, upgrade, and maintain web, database, ftp, mail, and other server and workstation software Ensures workstation/server data integrity Evaluate, purchase, install, configure, and test software before deploying it for use by others Manage software contracts and licenses Ensure the firewall and other software are appropriately configured to protect the system and are running 1.5.3 User Good communication with users is also a very important job for the system administrator. The success of system administration can be evaluated based on the user’s satisfaction. A system is useless without users. There are many different types of users surrounding the systems such as application developers, function users, CIO and CEO in a business environment; IT staff, students, faculty, and support staff in an academic environment. The system administrator should tell users what is being planned, what is currently being done, and what has been done recently. This information can be communicated via emails, phone messages, paper memos, etc. All system users need to access system resources but the needs are quite different. The developer always requires many more resources than end users. He or she needs a development server to conduct testing before moving products to the production server. The developer also needs to access more system software and application software than end users. The system administrator should provide technical support to the users. Different types of users will need different kinds of support and assistance. The system administrator only needs to provide the environment support rather than solve every specific problem a user may encounter. The system administrator should also provide users with training on any newly installed and upgraded system software and application software. 1.5.4 Documentation Documentation is one of the system administrator’s important duties, which should not be ignored. It includes documentation of the system configuration of servers, networks, web servers, database servers, software, and also non-technical documents such as ethics code, system wide policy and procedures. All these must be recorded in either electronic media or on paper. The documentation should include the logs of document creation date and persons or groups who made the document, and the change track records with reason for changes. The system wide technical document should includes the layout of network and all equipments, hardware configurations, software installed with its version and configuration, and all upgrade information. These documents will help the system administrator retrieve information or keep track of all system wide changes. It will also help any successor to more easily take over the job if there are any personnel changes. The ethics code may include issues related to honesty, privacy, copyright, and license contract issues. The policy documents may cover the user’s rights and responsibilities, in addition to the administrator’s rights and responsibilities. It should clearly state what the administrators and users are permitted to do and what they are not allowed to do. For instance, whether the administrator is granted the right to look at other people’s private e-mail or not. Also, the policy document should state the level of service users can request and what the administrator can offer, and the system resources allocated to each user, such as disk space and e-mail space. The procedure document may specify the steps of action a user should take to accomplish a certain task. These can be procedures for an application to assign a new account, request a new resource, request service or technical support, request technical training, or request a meeting related to system issues. The system backup, problem report, and software upgrading also have their procedures or guidelines to be followed. This book focuses on the technical aspect of system administration, which is listed as the first two categories. In the next section, you will practice installing the Fedora server, which includes the installation of Apache, MySQL and PHP that are included with Fedora. We chose the platform of Linux, Apache, MySQL, PHP(LAMP) as the theme of this book so that we can practice all server site administration plus the very popular application servers such as web server, database server, and server pages. Does a system administrator need to have good people skills? Why Active Thinking or why not? ? 1.6 Examples and Lab Practice 1.6.1 Fedora Pre-Installation In this lab section we guide you through the process of installing Fedora 9 server on 32bit PCs. If you do not already have a Fedora 9 DVD (One was provided with the text), you can download the software from http://fedoraproject.org/get-fedora and burn your own DVD. If you prefer to purchase a DVD, a number of vendors sell disks, such as Frozen Tech (http://www.frozentech.com/), Discount Linux (http://www.discountlinuxdvd.com/), and Lindistros (http://lindistros.com/fedora-p4.html). Price for a Fedora DVD including shipping should be less than ten dollars. When ordering or downloading you can choose a live CD or DVD instead of an installation DVD. Live media allows you to run directly from the distribution medium without installing on a hard drive. Note that to complete some of the exercises in the text you will need to install Linux on writeable media-either on a hard drive or a USB drive. To install Fedora from a DVD or run it using a live DVD, you will need to include the DVD drive in the boot sequence of your PC. To configure your machine to boot from the DVD you may need to change BIOS or CMOS settings. To access the BIOS setup utility, press the F2 key when the machine is starting. Some machines use keys other than F2; use whatever key your machine indicates for BIOS setup. If you do not see a message during startup about which key to use for BIOS setup, try one of the common BIOS setup keys, such as F1, F10, esc and delete. Before installing Fedora 9, you need to determine whether Fedora 9 is the only operating system you want on a computer or whether you want more than one operating system installed. To allow a machine to boot a different operating system, you will need to create separate hard disk partitions for each operating system. If there is already an operating system installed on a computer, such as Windows XP, as long as there is more than 20GB disk space available, you can perform the dual-boot partition installation with Fedora 9. Fedora server may need more than 20GB, depending on the size of applications to be installed with it. 1.6.2 Fedora Server Installation First, boot the machine from a Fedora installation DVD, and select the first option. The Fedora 9 is the most current version of Fedora Linux operating system. Skip the media test, because it takes a long time to complete Click the Next button on the welcome screen. Select English language as the language to use for installation. Select “U.S. English” or other appropriate keyboard layout. The next step, creating partitions for the Linux file system, is very important. Partitioning divides the hard drive into isolated sections (partitions) where each partition acts as if it were a separate drive. If multiple operating systems co-exist on the same machine, then each operating system requires at least one dedicated partition. Linux frequently uses several partitions. Note the option at the base of the screen to “Review and modify partitioning layout”. To install Linux, you must have enough space for the operating system files to be placed. To create a partition to hold the Linux files, there are five options shown on the next screen. For the default layout with a small boot section, select one of the first four options. If you prefer to customize your layout of the Linux file system rather than using the default settings, select the last option. If you want default file system layout and either have an empty disk or desire to erase everything on your existing disk, select the first option. The default layout generates three partitions. 1) Swap partition This partition provides a system with virtual memory. When there is not enough RAM, data is written to this swap partition. Linux allows users to set the size of the swap partition. Common settings are the same size as the amount of RAM on machine or twice the amount of RAM. For example, if a computer has 1GB of RAM, the size of swap might be 1GB or 2GB. Other values are legal and will affect performance. If the partiton is being heavily used, you might want to consider increasing the amount of RAM on the computer. 2) /boot partition holds the Linux kernel and bootstrap process files. The separated /boot partition is for protection of these import boot programs. 3) root(/) partition holds all system programs, application programs, user data, and packages. It is about 5GB. The first four partition options are for default layout. The default file system for Fedora is the ex3 file system based on ex2. The ex3 system is easier for file system recovery from crash over the ex2 system. You do not need to change this setting. Option1) Removes all partitions on the specified drives: it will install the new system to replace an existing Linux. Option2) Remove Linux partition on the specified drives: it will wipe out everything and install a new system. Option3) Allows one to resize existing partitions. Option4) Keeps all existing partitions and uses free space to create new partitions: it will install the new system on free space and retain your current partitions. Dual-boot system Dual-boot systems have two co-existing operating systems such as Windows and Linux. You can choose one of them to boot at machine start up time. If you don’t have any operating system installed on the machine, you can create a partition for Windows first and leave enough space (20GB) for Fedora. Of course, you can add a new additional hard disk drive, for example, an IDE drive, just for Fedora installation. This drive is assigned as hdb and hda is assigned to Windows partition. If you have two partitions on the first hard drive, they are recognized as hda1 and hda2 You can install Fedora on an existing hard drive or partition; just tell the installation program to install Fedora Linux in the designated drive (additional available disk drive) or partition (available free partition on the same drive where other OS is installed in different partition). Fedora even includes an option to resize existing partitions to create space to install Fedora. On the next screen, set the /swap partition size to be twice as large as RAM. The swap partition is for virtual memory. It is used as an extension to RAM, if the computer runs short of RAM. Next, create a 100 MB /boot partition to hold the system boot program Now create the system root (/) partition. The three partitions created so far are default partitions and are created in a standard installation. Users can create additional partitions during installation if desired. The sequence of creating partitions is not important. Here we create a separate /home partition where each user stores his data and programs in their own home directory so that user data is placed in a separate partition from system data. You may also want to create a /usr partition to hold application programs shared by all users. The size of each partition depends on your environment. For example, if the system has many users or users have large data and programs, then you need to allocate much more space for the /home partition. Here is the summary list after you configured the partitions. The following two screen shots show the progress of partition creation. It will take a while to complete the disk writing. Next, you decide on the boot loader. The boot loader is used to load the operating system. Without a boot diskette, a boot loader should be installed. When the machine starts, the BIOS reads the master boot record (MBR), which is located in the first sector (1024 bytes) of the hard disk. The master boot record holds a part of, or all of, the boot loader program and the partition information table. With the read data the BIOS activates the boot loader. The MBR can only hold one boot record for one operating system due its limited size. If you need to boot multiple operating systems, the system must use a boot loader. The boot loader will determine which operating system to load and then transfers the control to that system kernel software; the kernel then initializes the operating system. Linux Loader (LILO) and GRand Unified Boot loader (GRUB) are two popular boot loaders that come with Linux distributions. The LILO is an older Linux boot loader. GRUB is a newer boot loader tht is installed by default. GRUB can load a variety of open source operating systems as well as proprietary operating systems. GRUB has an interactive command interface and supports booting from a network. GRUB can always perform boot loading in its default command-line interface, even if the configuration file is configured incorrectly. Now, you need to configure the network settings for the computer. The default setting is Dynamic Host Configuration protocol (DHCP) where the IP address will be assigned by your Interface Service Provider (ISP) each time you have your own ISP. If you have an assigned IP address, click on the Edit button to enter static IP configuration mode. Linux will detect the network interface cards automatically and let you enter additional information by typing in values. This allows you to enter a static IP address and subnet mask to specify the host and network in IPv4 format. You can re-configure the machine to use a static IP address after you complete the installation. If you do not know the address now, you can set it later. If you are installing Fedora on a machine in an academic lab as part of a course, ask your instructor what values to use for your network settings. Internet Protocol version 4 (IPv4) is the fourth version of the Internet Protocol (IP), but it is the first version of the protocol to be widely used. IPv4 uses 32-bit (4-byte) addresses, which limits the address space to 232 or 4,294,967,296 possible unique addresses. The rapidly growing number of computers connected to the Internet is expected to soon exceed the 4,294,967,296 addresses available; forcing the adoption of IPv6 that uses 128 bit addresses. We use IPv4 addresses in this text, since that is what is commonly in use today. IPv4 uses dot-decimal notation (182.126.0.1) to represents an IP host address. The following step sets the host IP address and its subnet. The next setting is for the network interface card configuration, the server’s gateway(to access internet outside the LAN), the primary DNS and Secondary DNS. The Domain Name Server (DNS) is used to convert host names into IP addresses (ex: 192.168.1.94) only. A detailed discussion of these settings and their meanings is provided in the networking chapter. Press the ‘Edit’ button at the top right and enter the IP address, network mask and disable IPv6 support. Then manually set hostname (domain address), gateway, and DNS servers. Your numbers should not match those shown here. You have now completed setting up networking on the server. The next step is to set the time zone. Then assign the root account password here. When you install Fedora Linux you can also include many application packages such as Apache Web server. Install the KDE GUI desktop software and the GNOME GUI software. You can install many server component packages on the software packages screens. To complete exercises in other chapters you will need DNS Name Server, FTP Server, Mail Server, and My SQL Database. After selecting all the additional software packages that you would like to install at this time, launch the installation process, by clicking Next. Congratulations! It took you about 30-45 minutes to complete the entire Fedora installation. If you need to add more software packages after system installation, you can still install them using GNOME: System -> Administration -> Add/Remove Software or using yum command. The installation now allows you to create a user. For tasks that do not require root privilege, it is safer to use a regular user account instead of root admin account. The “john” account will be used in Chapter 2. Set up system date and time. Here is the first screen you will see after the system installation. Many system administration tasks can be performed from the GNOME desktop. Look for system administration tasks in the System -> Administration menu. 1.6.3 Post-installation setup 1) Add Additional Users: To complete the exercises in the next chapter, it will be helpful to have user groups defined and a few additional accounts. Create those now by logging in using the root account. At the GNOME desktop, click Systems -> Administration -> Users and groups. This will bring up a screen similar to the one below. The user “john” you created in the last section should already be listed. Create two additional users: susan and bill, in addition to john, that you created during the install. Click the “Add User” button at the top of the screen and then fill out the form shown below. The users you just will each belong to a group with the same name as their user names. Create a group named linux and assign all three regular users (bill, john, and susan) to this group. If you grant any access rights to a group for accessing files or directories, all members are granted the same privileges. After you have finished your listing of groups should look like the following. If you are missing users groups or users (these are the group members in the screenshot), you should add the missing entries before continuing. 2) Additional Configurations Some housekeeping configurations need to be taken care of after the installation. For example, you need to edit /etc/hosts file to replace server1.example.com with your new host name. The file /etc/hosts contains a mapping list of IP addresses and the host names that they correspond to. In general, /etc/hosts only contains entries for your local machine, and perhaps your name server or gateway. Your local name server will provide address-to-name mappings for other machines on the network, transparently. Edit /etc/hosts file to reflect this computer. Fedora includes several text editors. It does not matter which you use. Gedit is easy to use and available from the menus: Applications->Accessories->Text Editor. Alternatively, you can launch a terminal window and use vi, if you are familiar with this editor. To invoke vi, type: vi /etc/hosts in the terminal window [root@localhost etc]# vi /etc/hosts ‘ Regardless of the editor you choose to use, you need to add the fourth line. Use the IP number and domain specification of your machine. We used 192.168.1.93 and host1.domain.com but you values will be different. Use the same values that you used in the network configuration section. Also adjust the local loopback address, 127.0.0.1 to point to localhost as shown above. Eliminate references server1.example.com and server1. The system consults the /etc/hosts file to determine the IP address that corresponds to a host name, before consulting the DNS server for hostnames not included in the file. In order to guarantee all other services are up and running, you need to disable the SELinux by adding a line in the etc/selinux/config file. SELINUX=disable Alternatively, you can disable SELinux by using the menus at the top of the GNOME desktop: System -> Administration -> SELinux SELinux package provides extended security for Linux, which will be discussed in the Security chapter. In some cases, you may also need to temporarily disable firewall by firewall configuration of the GNOME desktop and enable it again later. After you finish configuring your networking and other configuration files, reboot your server so that the changes ttake effect. Reboot the server by including the –r reboot option in the shutdown command: shutdown -r now The following commands include the /sbin directory in the system environment variable $PATH definition so that you can freely run many system commands anywhere without specifying the directory path. The details will be discussed in the Linux environment chapter. root@localhost etc]# echo $PATH /usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/home /john/bin:/sbin [root@localhost etc]# PATH=$PATH:/sbin [root@localhost etc]# export PATH Use ifconfig command to check the configuration of the network interface card and run the route command to check the router configuration. The details of these commands will be discussed in the networking chapter. If the path command is not specified as indicated above use would need to use /sbin/ifconfig and /sbin/route to run the commands. [root@localhost etc]# /ifconfig eth0 eth0 Link encap:Ethernet HWaddr 00:1E:90:C1:3E:9D inet addr:192.168.1.93 Bcast:255.255.255.255 Mask:255.255.255.0 inet6 addr: fe80::21e:90ff:fec1:3e9d/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:30131 errors:0 dropped:0 overruns:0 frame:0 TX packets:17709 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:44321988 (42.2 MiB) TX bytes:1400710 (1.3 MiB) Interrupt:22 Base address:0xa000 [root@localhost etc]# /route -nee Kernel IP routing table Destination Gateway Genmask MSS Window irtt 192.168.1.0 0.0.0.0 255.255.255.0 0 0 0 192.168.122.0 0.0.0.0 255.255.255.0 0 0 0 0.0.0.0 192.168.1.254 0.0.0.0 0 0 0 Flags Metric Ref Use Iface U 0 0 0 eth0 U 0 0 0 virbr0 UG 0 0 0 eth0 3) LAMP start-up This is the time to start up Apache, My SQL, and PHP after the system installation. You can launch command line terminal by: Application->System Tools -> Terminal At system prompt, check whether HTTP Apache , PHP, and MySQL installation are in place using the rpm command as shown on the screen below. If the necessary files are not in place, you can use yum to install all LAMP relevant packages as shown below. One you have verified the software is installed, start the mysqld service for MySQL and the httpd service for Apache. Alternatively, you can use GNOME’s Add/Remove Software manager to search for and install packages as shown below. Menu Location is: System->Administration-> Add/Remove Software The next step is to start up the all relevant daemon and services and list their run-level status. The service run level 0-8 will be discussed in detail later in the text. You can use graphical tool ntsysv by typing netsysv at the terminal prompt to set a service to automatically start when the system is rebooted. Now, test that PHP is working correctly on your computer. Apache HTTP server comes with PHP module which will start when httpd starts. If you use any Web browser to browse the http://localhost you should see the PHP default page. It tells you that the Web server is up running. The Apache has its default virtual root directory at /var/www/html as shown here. Since it is the root directory, if you want to access the test.php in this directory, you don’t need to specify the full directory path. Enter http://localhost/test.php for the address in your Web browser. If you are connected to a network or any other machine (can even be a Windows machine) connected to this server with Ethernet cable, you can use ping your server from another computer to check the network is working and allowing connections. You should also be able to use a web browser to display the default page be specifying the IP address of your server. You can also install an optional GUI PHP admin package phpMyAdmin to make administering a MySQL database easier. If you do not do it now, you will install it in chapter 9 to complete some of the exercises in that chapter. The installation procedure is shown below: Finally, check the installation of the MySQL server software. We will use the DBA root account for this test. Root is a fully privileged account created during the installation of MySQL. In MySQL the root account does not have a password initially, but it is strongly recommended that you assign it a password when you login. Assigning the password will be covered in Chapter 9. Log in to your MySQL server by typing “mysql –u root” at the shell prompt. If you succeed in connecting to the Server, you should get a welcome message and the “mysql>” prompt. You can get out of mysql by typing exit at the mysql> prompt. MySQL also provides an administration utility, mysqladmin, to help in configuring and maintaining a database server. For help in using this utility, type “mysqladmin -?” at the Linux shell prompt. Summary Linux is a freely distributed, multitasking, multi-user UNIX like operating system. We use Fedora in this book because it is widely used, runs on PCs, and is free. Because of the similarity between Linux and UNIX, if you master system administration in Linux you will also be able to administer UNIX and other UNIX like platforms. You can even apply the system administration principles learned on Linux to administering Windows servers, although some of the actual commands used to administer Windows require a different syntax or have different names. The target audience of this book is IT students they may become system administrators, information system managers, directors of IT departments, and other high rank individuals in IT related areas. Therefore, we discussed the duty and scope of system administrator and aspects of system administrative tasks. The system administrator not only needs to have technical knowledge of system administration, but also needs to have people skills, technical writing skills, and management skills. In this chapter, we discussed the selection of various Linux distributions based on the popularity, usage(client/server), GUI interface availability, cost, software package support, and other attributes and features. The Linux architecture was explained, including the Linux kernel, Linux shell, and shell scripts. In the last section of the first chapter, Example and Lab Practice, step by step directions walked you through the installation of Fedora server with Apache web server, MySQL database server, and PHP software. The use of Fedora RPM was explained. You also used Fedora’s graphical interface to create users and groups. The successful Fedora server installation will provide you the ability to continue with the material in coming chapters. Self-Review Questions 1. Which Linux distribution is best known for its LiveCD? a. b. c. d. 2. The leader free open source Linux distribution is . a. b. c. d. 3. SUSE Fedora Dedian Knoppix SUSE Slackware Dedian Fedora GNOME, as a component of GNU project, is to provide free user friendly desktop interface a. False b. True 4. Linux is Unix a. True b. False 5. Linux user can’t access hardware directly from command line, must use shell . a. Falsr b. Frue 6. The default Linux shell is . a. b. c. d. 7. Korn shell C shell Born shell Bash shell A system admin only need to have technical administrative skills. a. True b. False 8. Web and database administration may also be part of system admin’s duty depending on the company and organization. a. True b. False 9. Most Linux server operations require root privilege to execute. a. False b. True 10. The default Linux shell is a. b. c. d. Korn shell C shell Bourne shell Bash shell 11. The number of partitions in the Linux standard installation is a. 1 b. 2 c. 3 d. 4 12. /usr partition is used to hold all user home directories a. True b. False 13. The “/” partition is the home directory of the root user. a. True b. False 14. The /sbin must have its own partition because many important comands are available there a. True b. False 15. User and group management tasks can be done either by Linux command lines or by GNOME desktop of a. True b. False 16. Which one is name of a partition a. /dev/sda3 b. /home 17. PHP is a Web server a. True b. False 18. PHP must have support of Apache in LAMP a. True b. False 19. One user can be assigned to multiple user groups a. True b. False 20. A server should have its static IP instead of using Dynamic Host Configuration protocol (DHCP) a. True b. False Keys to the self-Review Questions 1. D 2. D 3. B 4. B 5. B 6. D 7. B 8. A 9. B 10. D 11. C 12. B 13. B 14. B 15. A 16. A 17. B 18. A 19. A 20. A 1.7 Exercises 1. Download a Linux LiveCD or LiveDVD and boot this Linux from the media where Linux is loaded. 2. Install a dual boot Fedora Linux co-existing with Windows on separate partitions on the same machine. 3. Install a server version Fedora following the tutorial in the lab section of this chapter 4. Use man manual utility to find the detailed descriptions of the shell commands listed in the shell section of this chapter. 5. Run each shell command listed in the shell section of this chapter. 6. Switch from one shell to another shell and come back to default shell 7. Display the current shell using echo $<shell variable> command 8. Login yourself as root, create a user, then logout the root user, login as the user you just created. 9. Practice vi editor and emacs editor by yourself, please reference vi and emacs by man tool. 10. Run your first shell script.