Booting and Shutting Down
Booting and Shutting Down
Booting and Shutting Down
What is Booting? It is the initial set of operations that a computer system automatically performs when power is switched on.
Operating System
Just installing Linux operating system on the hard disk would not be able to do much. What makes Linux powerful and useful ? The services known as Daemons. These daemons typically run without user intervention providing everything from printing to file services to Web pages and beyond. Because they are not part of the operating system, they are normally loaded separately from the kernel. Many of these services could be made part of the Kernel, they are mostly separate programs.
Loading of Kernel
After the loading of kernel the First function is to start th init process. The init process starts all of the daemons at the appropriate time. A mechanism is provided to stop the daemons automatically.
POST
POST Power on Self-test. The task of POST is to locating and initializing peripheral devices, then finding, loading and starting up an OS.
BOOT STRAP
Boot Strap- means to pull oneself up by ones bootstrap. A computer cannot run without first loading software but some software must execute before any software can be loaded. The discovery of IC (ROM) allowed the computers to shipped with a start up program that could not be erased.
Kernel Initialization
Linux implements a two stage boot process. First Stage- BIOS loads the boot program called as Initial Program from the hard disk to the RAM. Second Stage The boot program loads the OS kernel vmlinuz into RAM.
System processes
Once the hardware initialization is complete the kernel will create number of spontaneous processes or programs in the user space. The various processes are: Init Keventd Kswapd Kupdated bdflush Then init is in the user space and only processes in the user space can be controlled by us, not others.
Startup Scripts
The startup scripts are establised in /etc/rc.d/init.d folder of Linux machine. The importa nt tasks performed by startup scripts are 1. Set the name of the computer 2. Set the time zone 3. Check the hard disk with fsck 4. Mount system disk 5. Remove old files from/tmp partition 6. Configure network interfaces with correct IP address Startup deamons and other network services.
Runlevels 0 1 or s 2 3 4 5 6
Description Shutdown Single user mode Multiuser mode without nfs full multiuser mode not used X windows reboot
For each runlevel there is a corresponding folder in the /etc folder. In linux everything is a file. The name of the symbolic links starts with the letters s or K followed by number and the name of the startup script/service to which it is linked. Example : the files in runlevel 2 and 3 are /etc/rc2.d/K20nfs ->../init.d/nfs /etc/rc2.d/S55named -> ../init.d/named
Multiuser Operation
Though the system has been booted to a specific runlevel, none of the users can login to the system until init spawns getty processes on terminals. If the system is booted to runlevel 5 init requires to spawn the graphical login system gdm.
Boot Loader
It is a computer program that loads the main os or runtime environment for the computer after the completion of self-tests in to RAM. When computer is powered on there is no os in ROM and RAM. The computer executes a small program stored in ROM from which the os and data may be loaded into RAM. The small program that begins this sequence is known as bootstrap loader or boot loader. Second-Stage Boot Loader Like GRUB,BOOTMGR,Syslinux are not os themselves, but are intelligent to load the os properly and transfer execution to it. Network booting Computers are able of booting over a computer network a) os is saved on the disk of a server. b) some part of OS is transferred to client using simple protocol like TFTP(Trivial File Transfer Protocol). Once the parts are moved the os takes over the control of booting process.
GRUB LOADER
GRUB(Grand Unified Bootloader) It is a boot loader component of loading a variety of free and proprietary os. GRUB works well with Linux,windows etc. Most mordern linux distributions use GRUB as the defauly boot loader during installation. GRUB is dynamically configurable. GRUB chains Logical block address mode.
Working of GRUB
After computer boots, the BIOS transfers the control to the first boot device ie hard disk, CDROM or any other BIOS-identified device. First sector on hard is called Master Boot Record(MBR). This sector is 512 bytes and contains a small piece of programs (446 bytes) called primary boot loader.
The MBR code looks for the active partition on the hard disk and one established it loads its boot sector into memory and passes control to it.
STAGES IN GRUB
Stage 1- The image used in this stage is essential and is used for booting up GRUB in the first place.It is usually embedded in the MBR of a disk or in the boot sector of the partition. The file used in this stage is named as stage 1. A stage 1 image can next either load stage 1.5 or load stage 2 directly.
File System
File system Also known as information management module. The main function of Information management module is to control each and every activity regarding information storage on secondary memory. File The information stored on secondary memory is called as file. The information is stored in the secondary memory in the form of files so it is called as File System. File contains its own title called Filename. File name is the sequence of Characters. Filename contains its extension i.e. it specifies the file type. In Unix System, the files have more than one file name extension. Example- emample.tar.z . The file is first achieved using the tar command and then compressed using compress command.
Types of Files
Types of Files
Text
Executable
Source Musical library Batch file Object File Multimedia Picture
Text files- Stores text i.e. set of characters. Executable files- Stores machine language program so that they are directly executable. Source file- These are text files use to store high level language programs. Library files- store library functions. Batch files Store commands of OS. Object files Store machine language program. Not directly executable as it is not linked with internal and external object. Musical files Stores musical data. Multimedia files stores files related multimedia. Picture files Stores pictures.
File Attributes
Name-It is the logical name of the file and is represented through symbols. Identifier- It is unique number that identifies the files in the file system. Location- The address of the file on a disk Type- It tells the type of file ie text file or executable file etc. Size It mentions the current size of the file Protection It specifies whether the file is read write protected to control access, hidden etc. Usage count File is opened by how many users. Time and date It contains time and date at the time of creation and modification. User information It stores the information like the file is created by which user and how it is accessible to other users.
Operations of files
File pointers It denotes the location of file which is currently accessible for read or write operation. File open count It counts the total files opened. File modes- The various modes through which file can be opened are Input mode,Output mode and Input Output mode etc. Reading,writing and other operations- When file is created the following operations are performed on it like writing a file,reading a file, deleting a file etc.
The directories may also contain the Subdirectories for more categorization. The UNIX file system is called hierarchical file system or tree structure file system which is upside-down. Pathname It is a sequence of component names separated by slash characters, a component is a sequence of characters that designated a file name that is uniquely in the component.
The concept of i-node i-node is the fundamental building block of Linux/Unix file system. The control information in the i-node includes files owner,permissions,size,time of last access,creation time, group ID etc. The one information which the i-node doesnt provide is the file name.
Superblocks
Th size first piece of information read from a disk is its superblock. This data structure reveals several key pieces of information like disk geometry,amount of available space, the location of the first inode. Without a superblock on-disk file system is useless.
Ex- If a program needs to encrypt a password the user should not open the etc/passwd file rather it should call the system library function getpw(). This type of function is known as system call. File system- The kernel provides an interface to display some of its data structure so that it can be useful for determinig the system parameters like interrupts used, devices initialised, memory statistics etc. Conf files- Most of the conf files in Red Hat Linux are in etc/directory .
Most of the Red Hat config files fall within a few different functions like system duties such logging and automatically running the programs with corn. Classification of Config files /etc/host.conf Describes the network domain server how to look up hostnames i.e /etc/hosts,then server name. /etc/hosts it contains a list of known hosts in local network.Can be used if IP of the system is not generated.
/etc/issue & /etc/issue.net These files are read to print a Welcome string to the user connecting from a terminal. They also contain few lines like Red Hat realease number,name, and Kernel ID. /etc/fstab fstab contains important information about your files system like what file system type the partitions are, where are they located on the hard drive and what mount point is used to access them. /etc/grub.conf- Grub stands for Grand Unified Bootloader.It offers a graphical interface giving a basic choice b/w which installed os kernels you want to run.The/etc/grub.conf file is a symbolic link to the actual file that is located in /boot/grub/grub.conf.
Etc/corn- Corn is a daemon that executes commands according to a preset schedule that a user defines. It wakes up every minute and checks all cron filesto see what jobs need to be run at that time.
TCP/IP layer The network address layer and Media access control MAC address Network Classes Class A,Class B,Class C,Class D and E. NIC Network Interface Card it is a hardware device which a computer uses to send data around the rest of the network.
To Set up NIC
Before configuring the NIC we have to ensure that the loopback device with IP address 127.0.0.1 is working. With the ifconfig command line we can see the current network interface configuration. This command will show a device called lo with the address 127.0.0.1(this will be displayed only when the loopback is configured).
If loopback is not configured we can add it through the following command: Ifconfig lo 127.0.0.1 The system can also be provided with more information about the device by route command like: Route add net 127.0.0.0 To configure the NIC we use ifconfig command and eth0 for Ethernet device.We also require the router,IP address, the net mask, DNS and broadband address.
The command line for configuring the NIC is : ifconfig eth0 <>netmask<>broadcast <> A file ifconfig-eth0 is created in /etc/sysconfig/network-scripts. This file shows the information along with the details by us earlier. After configuring the NIC on each computer in the network we have to modify the following files present in /etc directory: /etc/nsswitch.conf it contains all the configuration information for the name resolver. host: files dns /etc/hosts This file contains all the computers on the network ie local or outside network. /etc/resolv.conf This file provides information regarding the name servers used to resolve hostnaes.
The /etc/resolv.conf file contains the following lines: NETWORKING=Yes HOSTNAME= (host and domain name of your system)
Subnetting
Subnetting The practice of dividing the network into two or more network. This define the network connection with the outside world. This includes configuring a router, obtaining an IP address and making the connection.
/etc/sysconfig/network How IP addresses work with the subnetting 1) IP numbers are assigned to network interfaces on hosts. 2) Many computers can have a single network interface and a single IP number. 3) We Use ifconfig and route commands to assign more than one IP address to a single NIC. Example : ifconfig eth0:1 192.168.1.4 Route and host 192.168.1.4 dev eth0
The command provides the IP address to the virtual interfaace eth0:1 The second command adds a route for the address to the actual device eth0. An IP address ia a unique address used to identify a device on an IP network. The address is made up of 4 bytes .They are broken into four octets. Each octet is of 8 bits and is converted to decimal format and separated by dots.
NFS- It is a Network File System. Networking services provides sharing of files via a network file system. (NFS) In Linux NFS is supported by the Kernel. NFS was developed by Sun Mircosystems in 1980. NFS acts as a protocol that allows communication between different computing environment.
It stores the files on a network allows users to treat the remotely accessed files as if they were local. NFS allows to access files and directories that are located on another system using standard linux commands. In this system the administrator provides a central server. The files accessed on a central server is completely transparent to the client which provides file locking and management to prevent the files from getting corrupted by other users. NFS is based onClient-Server Relationship. In NFS the act of making file system available is called exporting.
The NFS client mounts the exported files system locally the same way as local files are mounted. This is known as NFS mount.
Versions of NFS
NFS version 2 NFSv2 is older and is widely supported. It is operated over user datagram protocal. NFS version 3- NFSv3 has more features,including 64bit file handling, it handles files larger than 2 gigabytes(GB) NFS version 4 NFSv4 works through firewalls and on the internet. Implementation of NFS version 2 and 3 are similar whereas version 4 is slightly different.
NFSv2 and NFSv3 are stateless ie the server does not retain any information of the client transaction. NFSv4 is stateful as it retains the information of the client transaction. NFS Advantages 1) It provides centralised management. 2) NFS allows user to log into any server and have access to their files tranparently via IP addresses,groups,users etc. 3) It saves disk space and prevents dulication of resources. 4) Users protect their vital information by storing it into NFS mounted file system which is regularly backed up.
Disadvantages of NFS
1) The main disadvantage of NFS is security issue. 2) NFS slows down the performance during heavy network traffic. 3) Its architecture is one of its disadvantage.
SMB is the standard protocol used by the Microsoft Windows network file system. Samba is beneficial if we have a network of both Windows and Linux .
Check Samba Installation To check the samba installation on the system type the following command in the terminal window: rmp q samba If Samba is not installed on the system, the command displays an output showing Samba is not installed. If Samba is installed , the rmp query returns the version number of the samba program installed on your system:
Samba-3.4.7-0.50.fcll.i586 Samba can be downloaded from the sambas web site: www.samba,install it by typing the following command in the terminal window: Yum y install samba samba-client samba-swat system-config-samba Before making samba connection with windows PC it needs to be configured. The samba configuration file is smb.conf which is located in the /etc/samba directory. SWAT is the Sambas web based configuration tool that enables to configure smb.conf file graphically.
Before editing the smb.conf file the following commands needs to be run to configure Samba: 1) Using chkconfig command we can configure Samba and SWAT to start at boot time. The commands to start Samba and Swat are: chkconfigsmb on chkconfig swat on We can start/stop/restart Samba after boot time using the following command: Servicesmb start/stop/restart Before using SWAT, the xinetd program which controls the SWAT must be activated .
We can start/stop/restart xinetd after boot time using the following commands: servicexinetd start/stop/restart Samba does not need to be restarted after making changes to configuration file. After running the following commands we need to configure smb.conf file. This file contains the runtime configuration information for the smba programs. The file consists of different sections , beginning with the name of section in the square brackets and continues until the next section begins. There are three special sections: [global],[home] and [printers]
Global Section
It is the first section of the smb.conf file. Contains general samba cofiguration parameters that apply to the entire server . Home Section In this section the treatment of user logins are defined. It provides fast and simple services to a large number of clients to access their home directories with minimal efforts.
It provides options like browseable and writable by which we can restrict the access of home directories to specific guests. [Printers] It is the section which provides configuration to printers. It allows clients to set print options to the specified directory. Options available under this section: [printers]
This command will add a user with name bob. We can add a linux password for the new user as follows: Passwd bob The terminal will prompt you to change password for the user bob: Changing password for user bob New password: ****** Retype new password: ******
This command can be repeated to add user accounts for all users form Windows workstation to give access to the Linux system. The following command can be typed to create Samba password file (smbpasswd) on Fedora Linux system: Cat/etc/passwd | mksmbpasswd.sh >/etc/samba/smbpasswd This command creates only the users account, not their password. We need to create password for users by using the smbpasswd command as follows:
Smbpasswd bob New SMB password: ****** Retype new SMB password: ******
To query the network for Samba server findsmb command is used The smbmount utility provides the following command: Smbmount//computer name/directory/mysystem/mount/point The success of the mount can be checked by the Ls command on the directory. To test the connection on the Windows PC the following steps are performed: 1) On windows computer double clink the network places window. 2) A list appears including the icon of the Linux system. 3) Double click icon to see all the shares. 4) A window appears prompting for username and password to enter the directories. 5) Files can be shared between Linux and Windows computer for providing login credentials.
NTP Installation
Linux system is preinstalled with NTP pacakage, if not then the following task has to be performed: i) Install the NTP software. ii) Locate suitable timeservers to act as a reference clock. iii) Configure your local timeserver iv) Start the NTP daemon on the local timeserver. v) Check whether NTP daemon is responding to requests. Installing NTP is simple process. To check that NTP package is installed in the system the following command is used: $ rpmqueryntp The following command returns an output showing the version number of NPT installed in the system: Ntp-4.2.4p7-2.fc11.i586
Reference Clocks
Timeservers serves accurate time after synchronizing its time with one or more reference clocks or master clocks. NTP works on distributed platform ie the servers and clients are spread worldwide, any given client can request a time check from any given server. NTP uses hierarchical system of levels of clock sources known as Stratum to reduce the load on any server set of servers.
DNS Domain Name System provides a lookup mechanism that translate domain names into IP addresses. The Internet works on the bases of IP addresses. Whenever the DNS is used the DNS service translates the name into the corresponding IP address. Ex- the domain name www.demonstration.com might translate to 198.123.124.7. Ex- welfare.com , the first part of this domain name is the name of the institution, company or organization. The second part after the dot (.) is called the top-level domain (TLD). Examples of TLD are: - com used for business,edu used for educational institution, mil- used for military institutes,netused for network affiliated organizations etc.
When a host name is typed , the system uses its resources to resolve names into IP addresses. It basically looks in /etc/nsswitch.conf file for the host information.
B) Slave:- It maintains the backup of the master server. It is used when master server goes down or is not available. C) Caching:- it is used to provide information to other servers and workstations on the local network. Caching server speeds up searches as the domain information is already stored in memory.
There are five files that are required to set up the DNS server: 1) named.conf this file is located in /etc directory and contains global properties and sources of configuration file. 2) Named.ca this file is located in /var/named directory and contains the name and addresses of the root servers. 3) Named.local this file is located in /var/named directory and provides information for resolving the loopback address for the localhost. 4) Zone this file contains the names and addresses of servers and workstation in the local domain and provide mapping of these names to IP addresses. 5) Reverse zone this file provides information to map IP addresses to names. note the first three files are required irrespective of the configuration as a master, slave or caching, only the last two files are required for the master domain server. To start the BIND server, /etc/rc.d/init.d/named script is used
Named.conf
The following configuration statements are used in the named.conf file i) Options it contains the default and the global configurations. ii) Include it includes the information from another files. iii) Acl it specifies the IP addresses used in an access control list. iv) Logging it specifies log file locations and contents. v) Server it specifies remote server properties. vi) Zone it provides zones information. vii) Key it specifies security keys used for authentication.
Add the following for the reverse lookup: zone 1.168.192.in-addr.arpa { Notify no; Typeslave; File tac.rev; Masters {192.168.1.1;}; }; After modifying the /etc/named.conf file the configuration of the slave server is complete.
Always use the same names for the files on the master server as the slave server, as these files are downloaded by the slave in a zone file transfer and stored on the slave in the files . After the following changes, restart the named daemon using the following command: Service named restart The name server is ready to use after all the above steps.
Mail User Agent(MUA) it allows a user to read and compose email messages. It is widely referred to as mail client.It provides users an interface for reading and writing email messages. Two types of MUAs available i) GUI and ii) CLI both provides same functions. Mail Transfer Agent (MTA) it is a program that is responsible to send the message across the network. MTAs work without intervention of the user, as most of the users are not aware of MTA. Mail Delivery Agent (MDA) it receives the message form the MTA. It stores it into the new message in the recipients mailbox file kown as mail spool. In many cases MDA is actually a Local Delivery Agent (LDA). NOTE The default MTA installed in Fedora core is called the Sendmail and popular MDA installed in Fedora core is proc mail.