Archive for September, 2007

151Chapter 4Learning Basic AdministrationHere is an example of (Cheapest web hosting)

Tuesday, September 18th, 2007

151Chapter 4Learning Basic AdministrationHere is an example of the modprobecommand being used to load the parport mod- ule, which provides the core functions to share parallel ports with multiple devices: # modprobe parportAfter parport is loaded, you can load the parport_pc module to define the PC-styleports available through the interface. The parport_pc module lets you optionallydefine the addresses and IRQ numbers associated with each device sharing the par- allel port. For example: # modprobe parport_pc io=0×3bc irq=autoIn this example, a device is identified as having an address of 0×3bc, and the IRQ forthe device is autodetected. The modprobecommand loads modules temporarily they disappear at the nextreboot. To permanently add the module to your system, add the modprobecommandline to one of the startup scripts that are run at boot time. An alternative to using modprobeis the insmodcommand. The advantage of usingmodprobe, however, is that insmodloads only the module you request, whereasmodprobetries to load other modules that the one you requested is dependent on. Removing ModulesUse the rmmodcommand to remove a module from a running kernel. For example, to remove the module parport_pc from the current kernel, type the following: #rmmod parport_pcIf it is not currently busy, the parport_pc module is removed from the running kernel. If it is busy, try killing any process that might be using the device. Then run rmmodagain. Managing File Systems and Disk SpaceFile systems in Linux are organized in a hierarchy, beginning from root (/) and continuing downward in a structure of directories and subdirectories. As an admin- istrator of a Linux system, it s your duty to make sure that all the disk drives thatrepresent your file system are available to the users of the computer. It is also yourjob to make sure there is enough disk space in the right places in the file system forusers to store what they need. Note10_

Web server certificate - 150Part IIRunning the Show# lsmodModule Size Used bysnd_seq_oss

Monday, September 17th, 2007

150Part IIRunning the Show# lsmodModule Size Used bysnd_seq_oss 38912 0snd_seq_midi_event 9344 1 snd_seq_osssnd_seq 67728 4 snd_seq_oss,snd_seq_midi_eventsnd_seq_device 8328 2 snd_seq_oss,snd_seq… autofs 16512 0ne2k_pci 9056 08390 13568 1 ne2k_pciohci1394 41860 0ieee1394 284464 1 ohci1394floppy 65712 0sg 36120 0scsi_mod 124600 1 sgparport_pc 39724 0parport 47336 1 parport_pcext3 128424 2jbd 86040 1 ext3This output shows a variety of modules that have been loaded on a Linux system, including several to support the ALSA sound system, some of which provide OSScompatibility (snd_seq_oss). To find information about any of the loaded modules, use the modinfocommand. For example, you could type the following: # modinfo -d snd-seq-oss OSS-compatible sequencer module Not all modules have descriptions available. In this case, however, the snd-seq-ossmodule is described as an OSS-compatible sequencer module. You can also use the-aoption to see the author of the module, or -nto see the object file representingthe module. The author information often has the e-mail address of the driver s cre- ator, so you can contact the author if you have problems or questions about it. Loading ModulesYou can load any module that has been compiled and installed (to the /lib/modulesdirectory) into your running kernel using the modprobecommand. A common rea- son for loading a module is to use a feature temporarily (such as loading a moduleto support a special file system on a floppy you want to access). Another reason isto identify a module that will be used by a particular piece of hardware that couldnot be autodetected.

149Chapter 4Learning Basic AdministrationConfiguring HardwareIn (Hosting your own web site) a perfect world,

Monday, September 17th, 2007

149Chapter 4Learning Basic AdministrationConfiguring HardwareIn a perfect world, after installing and booting Linux, all of your hardware is detectedand available for access. Although many Linux systems are rapidly moving closer tothat world, there are times when you must take special steps to get your computerhardware working. Linux systems come with tools for configuring the drivers that stand between theprograms you run (such as CD players and Web browsers) and the hardware theyuse (such as CD-ROM drives and network cards). The intention is to have the driversyour system needs most often built into the kernel; these are called resident drivers. Drivers that are added dynamically as needed are referred to as loadable modules. Finding Available ModulesIf you have installed the Linux kernel source code, source code files for availabledrivers are stored in subdirectories of the /usr/src/linux*/driversdirectory. You can find information about these drivers in a couple of ways: .make xconfig With /usr/src/linux*as your current directory, typemake xconfigfrom a Terminal window on the desktop. Select the categoryofmodule you want and then click Help next to the driver that interests you. The help information that appears includes a description of the driver. .Documentation The /usr/src/linux*/Documentationdirectory containslots of plain-text files describing different aspects of the kernel and relateddrivers. After modules have been built, they are installed in the /lib/modules/subdirecto- ries. The name of the directory is based on the current release number of the kernel. Modules that are in that directory can then be loaded and unloaded as they areneeded. Listing Loaded ModulesTo see which modules are currently loaded into the running kernel on your com- puter, use the lsmodcommand. Here s an example: If you don t have a Linux system installed yet, try booting KNOPPIX and usinglsmodto list your loaded modules. If all your hardware is working properly, writedown this list of modules. Later, when you permanently install Fedora or some otherLinux system, if your CD drive, modem, video card, or other hardware doesn t workproperly, you can use your list of modules to determine which module should havebeen used and load it, as described in the next section. Note10_

Web hosting e commerce - 148Part IIRunning the ShowTable 4-3useradd Options for Changing

Sunday, September 16th, 2007

148Part IIRunning the ShowTable 4-3useradd Options for Changing User DefaultsOptionsDescription-b default_homeSet the default directory in which user home directoriesare created. Replace default_homewith the directoryname to use (-b garage). Usually this is /home. -e default_expire_dateSet the default expiration date on which the user accountis disabled. The default_expire_datevalue shouldbe replaced with a date in the form MM/DD/YYYY (-e 10/15/2005). -f default_inactiveSet the number of days after a password has expiredbefore the account is disabled. Replace default_ inactivewith a number representing the numberofdays (-f 7). -g default_groupSet the default group that new users will be placedin.Normally useraddcreates a new group with thesame name and ID number as the user. Replacedefault_groupwith the group name to use (-g bears). -s default_shellSet the default shell for new users. Normally this is/bin/bash. Replace default_shellwith the fullpath to the shell that you want as the default for newusers (-s /bin/ash). To set any of the defaults, give the -Doption first, and then add the defaults youwant to set. For example, to set the default home directory location to /home/ everyoneand the default shell to /bin/tcsh, type the following: # useradd -D -b /home/everyone -s /bin/tcshBesides setting up user defaults, an administrator can create default files that arecopied to each user s home directory for use. These files can include login scriptsand shell configuration files (such as .bashrc). Other commands exist that are useful for working with user accounts, includingusermod(to modify settings for an existing account) and userdel(to delete anexisting user account).

Msn web hosting - 147Chapter 4Learning Basic AdministrationSetting User DefaultsThe useraddcommand determines

Saturday, September 15th, 2007

147Chapter 4Learning Basic AdministrationSetting User DefaultsThe useraddcommand determines the default values for new accounts by readingthe /etc/login.defsfile. You can modify those defaults by either editing that filemanually with a standard text editor or by running the useraddcommand with the-Doption. Although login.defsis different on different Linux systems, here is anexample containing many of the settings you might find in a login.defsfile: PASS_MAX_DAYS 99999PASS_MIN_DAYS 0PASS_MIN_LEN 5PASS_WARN_AGE 7UID_MIN 500UID_MAX 60000GID_MIN 500GID_MAX 60000CREATE_HOME yesAll uncommented lines contain keyword/value pairs. For example, the keywordPASS_MIN_LENis followed by some white space and the value 5. This tells useraddthat the user password must be at least five characters. Other lines let you customizethe valid range of automatically assigned user ID numbers or group ID numbers. (Red Hat starts at UID 500; other Linuxes start with UID 100.) A comment sectionthat explains that keyword s purpose precedes each keyword (which I edited outhere to save space). Altering a default value is as simple as editing the value associ- ated with a keyword and then saving the file. If you want to view the defaults, type the useraddcommand with the -Doption, asfollows: # useradd -DGROUP=100HOME=/homeINACTIVE=-1EXPIRE= SHELL=/bin/bashSKEL=/etc/skelYou can also use the -Doption to change defaults. When run with this flag, useraddrefrains from actually creating a new user account; instead, it saves any additionallysupplied options as the new default values in /etc/login.defs. Not all useraddoptions can be used in conjunction with the -Doption. You can use only the fiveoptions listed in Table 4-3.10_

146Part IIRunning the ShowEach line in (Web space) the /etc/passwdfile

Friday, September 14th, 2007

146Part IIRunning the ShowEach line in the /etc/passwdfile represents a single user account record. Eachfield is separated from the next by a colon (:) character. The field s position in thesequence determines what it is. As you can see, the login name is first. Again, thepassword field contains an xbecause we are using a shadow password file to storeencrypted password data. The user ID selected by useraddis 502. The primarygroup ID is 100, which corresponds to the users group in the /etc/groupfile. Thecomment field was correctly set to Mary Smith, the home directory was automati- cally assigned as /home/mary, and the command shell was assigned as /bin/tcsh, exactly as specified with the useraddoptions. By leaving out many of the options (as I did in the first useraddexample), defaultsare assigned in most cases. For example, by not using -g usersor -G wheel,sales, in Red Hat Linux a group named marywould have been created and assigned to thenew user. Likewise, excluding -s /bin/tcshcauses /bin/bashto be assigned asthe default shell. The /etc/groupfile holds information about the different groups on your Linuxsystem and the users who belong to them. Groups are useful for enabling multipleusers to share access to the same files while denying access to others. Peek at the/etc/groupfile, and you find something similar to this: bin:x:1:root,bin,daemondaemon:x:2:root,bin,daemonsys:x:3:root,bin,admadm:x:4:root,adm,daemontty:x:5: disk:x:6:rootlp:x:7:daemon,lpmem:x:8: kmem:x:9: wheel:x:10:root,joe,mary… nobody:x:99: users:x:100: chris:x:500sheree:x:501sales:x:601:bob,jane,joe,maryEach line in the group file contains the name of a group, the group ID number asso- ciated with it, and a list of users in that group. By default, each user is added to hisor her own group, beginning with GID 500. Note that mary was added to the wheeland sales groups instead of having her own group. It is actually rather significant that mary was added to the wheel group. By doingthis, you grant her the capability to use the sudocommand to run commands asthe root user (provided that sudois configured as described later in this chapter).

Web site layout - 145Chapter 4Learning Basic AdministrationWhen you choose a username,

Friday, September 14th, 2007

145Chapter 4Learning Basic AdministrationWhen you choose a username, don t begin with a number (for example, 06jsmith). Also, it s best to use all lowercase letters, no control characters or spaces, and a max- imum of eight characters. The useraddcommand allows up to 32 characters, butsome applications can t deal with usernames that long. Tools such as psdisplayUIDs instead of names if names are too long. Having users named Jsmith and jsmithcan cause confusion with programs (such as sendmail) that don t distinguish case. Next, set Mary s initial password using the passwdcommand. You re prompted totype the password twice: # passwd maryChanging password for user mary. New password: ******* Retype new password: ******* (Asterisks in this example represent the password you type. Nothing is actually dis- played when you type the password.) In creating the account for Mary, the useraddcommand performs several actions: .Reads the /etc/login.defsfile to get default values to use when creatingaccounts. .Checks command-line parameters to find out which default values to override. .Creates a new user entry in the /etc/passwdand /etc/shadowfiles based onthe default values and command-line parameters. .Creates any new group entries in the /etc/groupfile. (Red Hat creates agroup using the new user s name; Gentoo adds the user to the users group; and SUSE adds it to every group you set for new users, such as dialout, audio, video, and other services.) .Creates a home directory, based on the user s name, in the /homedirectory. .Copies any files located within the /etc/skeldirectory to the new homedirectory. This usually includes login and application startup scripts. The preceding example uses only a few of the available useraddoptions. Mostaccount settings are assigned using default values. You can set more values explic- itly, if you want to; here s an example that uses a few more options to do so: # useradd -g users -G wheel,sales -s /bin/tcsh -c Mary Smith maryIn this case, useraddis told to make usersthe primary group mary belongs to (-g), add her to the wheel and sales groups, and assign tcsh as her primary commandshell (-s). A home directory in /homeunder the user s name (/home/mary) is createdby default. This command line results in a line similar to the following being addedto the /etc/passwdfile: mary:x:502:100:Mary Smith:/home/mary:/bin/tcshTip10_

Apache web server tutorial - 144Part IIRunning the ShowTable 4-2(continued) OptionDescription-ggroupSet the primary

Thursday, September 13th, 2007

144Part IIRunning the ShowTable 4-2(continued) OptionDescription-ggroupSet the primary group (as listed in the /etc/groupfile) thenew user will be in. Replace groupwith the group name (-g wheel). -G grouplistAdd the new user to the supplied comma-separated list ofgroups (-G wheel,sales,tech,lunch). -kskel_dirSet the skeleton directory containing initial configuration filesand login scripts that should be copied to a new user s homedirectory. This parameter can only be used in conjunction withthe -moption. Replace skel_dirwith the directory name touse. (Without this option, the /etc/skeldirectory is used.) -mAutomatically create the user s home directory and copy thefiles in the skeleton directory (/etc/skel) to it. -MDo not create the new user s home directory, even if thedefault behavior is set to create it. -nTurn off the default behavior of creating a new group thatmatches the name and user ID of the new user. This option isavailable with Red Hat Linux systems. Other Linux systemsoften assign a new user to the group named users instead. -oUse with -u uidto create a user account that has the sameUID as another username. (This effectively lets you have twodifferent usernames with authority over the same set of filesand directories.) -p passwdEnter a password for the account you are adding. This must bean encrypted password. Instead of adding an encrypted pass- word here, you can simply use the passwdusercommandlater to add a password for user. -s shellSpecify the command shell to use for this account. Replaceshellwith the command shell (-s bash). -u user_idSpecify the user ID number for the account (-u 474). Withoutthe -uoption, the default behavior is to automatically assignthe next available number. Replace user_idwith the IDnumber (-u). For example, let s create an account for a new user named Mary Smith with a loginname of mary. First, log in as root, and then type the following command: #useradd -c Mary Smith mary10_

Web hosting solutions - 143Chapter 4Learning Basic AdministrationYou can add user accounts

Wednesday, September 12th, 2007

143Chapter 4Learning Basic AdministrationYou can add user accounts to most Linux systems in several ways Red Hat systemsuse the redhat-config-users utility, for example, and SUSE offers a user setup modulein YaST. This chapter describes how to add user accounts from the command linewith useraddbecause most Linux systems include that command. Adding Users with useraddThe most straightforward method for creating a new user from the shell is with theuseraddcommand. After opening a Terminal window with root permission, yousimply invoke useraddat the command prompt, with details of the new account asparameters. The only required parameter is the login name of the user, but you probably want toinclude some additional information ahead of it. Each item of account informationis preceded by a single letter option code with a dash in front of it. Table 4-2 liststhe options that are available with useradd. Table 4-2useradd Command OptionsOptionDescription-ccommentProvide a description of the new user account. Often the -c comment here person s full name. Replace commentwith the name of theuser account (-c jake). Use quotes to enter multiple words(-c jake jackson ). -d home_dirSet the home directory to use for the account. The default is toname it the same as the login name and to place it in /home. Replace home_dirwith the directory name to use (for example, -d /mnt/homes/jake). -DRather than create a new account, save the supplied informationas the new default settings for any new accounts that are created. -e expire_dateAssign the expiration date for the account in MM/DD/YYYYformat. Replace expire_datewith a date you want to use (-e 05/06/2005). -f -1Set the number of days after a password expires until theaccount is permanently disabled. The default, -1, disables theoption. Setting this to 0disables the account immediately afterthe password has expired. Replace -1with the number to use. Continued10_

142Part IIRunning the ShowThe preceding example grants a (Web site translator)

Wednesday, September 12th, 2007

142Part IIRunning the ShowThe preceding example grants a simple all-or-nothing administrative privilege toeveryone you put in the wheel group. However, the /etc/sudoersfile gives youanincredible amount of flexibility in permitting individual users and groups to useindividual applications or groups of applications. Refer to the sudoers and sudoman pages for information about how to tune your sudo facility. Administering Your Linux SystemYour system administrator duties don t end after you have installed Linux. If multiplepeople are using your Linux system, you, as administrator, must give each personhis own login account. You ll use useraddand related commands to add, modify, and delete user accounts. Configuring hardware is also on your duty list. When you add hardware to yourLinux computer, that hardware is usually detected and configured automatically. Insome cases, though, the hardware may not have been set up properly, and you willuse commands such as lsmod, modprobe, insmod, and rmmodto configure the rightmodules to get the hardware working. A device driver is the code that is permanently built into the kernel to allow appli- cation programs to talk to a particular piece of hardware. A module is like a driver, but it is loaded on demand. The Configuring Hardware section later in this chapterincludes information about using these commands to configure modules. Managing file systems and disk space is your responsibility, too. You must keeptrack of the disk space being consumed, especially if your Linux system is sharedby multiple users. At some point, you may need to add a hard disk or track downwhat is eating up your disk space (you use commands like findto do this). Your duties also include monitoring system performance. You may have a runawayprocess on your system or you may just be experiencing slow performance. Toolsthat come with Linux can help you determine how much of your CPU and memoryare being consumed. These tasks are explored in the rest of this chapter. Creating User AccountsEvery person who uses your Linux system should have a separate user account. Having a user account provides each person with an area in which to securely storefiles as well as a means of tailoring his or her user interface (GUI, path, environmentvariables, and so on) to suit the way that he or she uses the computer. Note10_