Mounting Floppy Disks and Removable Media To read floppy disks and other removable media with Red Hat Linux, you need to mount the device, just as you would any other file system. Red Hat has created mount points in the /mnt directory for just this purpose. The subdirectory, /mnt/floppy, is for mounting a single floppy disk at a time, while /mnt/cdrom is used to mount a single CD-ROM at a time. To mount an MS-DOS-formatted floppy, you would run: # mount -t msdos /dev/fd0 /mnt/floppy Recall that the -t option to the mount command specifies the type of file system we're mounting. The device, /dev/fd0, is the first floppy disk device. If you have a second floppy disk, the second device would be /dev/fd1. To mount both the first and second floppy at the same time would require another directory, such as /mnt/floppy2, as the mount point. The final argument tells mount which mount point to use. After you have mounted the floppy disk, any reads or writes you perform in /mnt/floppy happen on the floppy disk. The device for your CD-ROM is normally /dev/cdrom. To mount an IS09660 CD-ROM, run: # mount -t iso9660 /dev/cdrom /mnt/cdrom Now you can read the contents of /mnt/cdrom as if it were a normal file system on your system. To unmount a floppy or CD-ROM, use the unmount command with the mount point as an argument. The following commands unmount both our floppy and CD-ROM: # umount /mnt/floppy # umount /mnt/cdrom It is important you unmount floppy disks before removing them. Because of the way UNIX caches information before writing to disk, there is a good chance you'll lose data by simply removing a floppy without unmounting it. One system has a Zip drive of 100MB. The device is /dev/hdd and it was formatted as a Linux Native (Extended 2 File System) on the one partition /dev/hdd1. The directory /mnt/zip was created and a permanent entry in /etc/fstab was added to mount the device at every reboot. The command to manually mount the Zip drive was: # mount /dev/hdd1 /mnt/zip The command to manually unmount the Zip drive was: # umount /dev/hdd1 The command to eject the Zip drive (which automatically unmounts it) was: # eject /dev/hdd1 CERTIFICATION OBJECTIVE 4.10 Sound Cards and the sndconfig Utility Red Hat Linux provides a screen-oriented interface to make installing your sound card easier by setting up the necessary configuration files to run a sound card. If Plug-n-play (PnP) support is compiled in, (default for Rh 7.x) sndconfig will probe or PnP sound cards. Sometimes, however, this probe causes the machine to lock up, so you can disable probing by running sndconfig with the -noprobe option. If no cards are detected, or the -noprobe option was given, you'll be presented with a list of cards to choose from, shown in Figure 4-11. From there, you'll need to choose the I/O port, IRQ, and DMA settings for the sound card. These can be obtained by consulting your sound card documentation. Figure 4-11: sndconfig One other option, --noautoconfig, can be used when probing for PnP cards. Normally, sndconfig will determine the correct values to run the sound card. With --noautoconfig, you can set the settings yourself. Certification Summary This chapter covered basic configuration and administration of a Red Hat Linux system. We learned the steps necessary to create a basic user, how to populate a user's home directory with the templates in /etc/skel, and found out where window manager configuration files are located. We also covered the different types of file systems Linux uses, discussed how to mount them, and what mount options to use with them. In the section Using RPM, we learned the steps necessary to validate a package signature, how to add, remove, and upgrade packages, and how to add updates. We also talked about verifying packages, and how to see what package a file belongs to. We finished the topic with a discussion on installing SRPMs, and building RPMs from SRPMs and tar archives. In the Basic Networking section, we covered the configuration files in the /etc/sysconfig hierarchy, including files for the clock, mouse, static-routes, keyboard, network, and PCMCIA. We also discussed the ifup, ifdown, ifconfig, netstat, and arp commands. We concluded the chapter by talking about virtual consoles, the kbdconfig, timeconfig, and mouseconfig screen utilities, how to mount floppy disks and removable media, and lastly touched on the sndconfig utility. Lab Question In this exercise, you are going to experiment with a few other neat utilities for system management, one for service control called tksysv, and a set of user management utilities. From a XTerm in any X Window interface, start the graphical equivalent to chkconfig and ntsysv called tksysv. Run tksysv in the background so you can still use this terminal window. [root]# tksysv & This will present a graphical tool for controlling which services are to be run at any level. These next questions assume that the 'autofs' service is already running and installed, if not, pick another service to add and remove, it does not matter which as long as you put it back exactly as it was before. From within tksysv, edit the autofs record, record the current order number. Remove the autofs service from Level 3. Switch back to the XTerm window and run chkconfig to see if it has been removed. Add the autofs service back in with order number 29. Switch back to the XTerm window and run chkconfig to verify it is back. Although tksysv is a nice graphical interface, the chkconfig utility is probably faster and easier to remember, especially since X is not always available in an emergency or through remote login. Lab Answer Linuxconf is a large utility that does it all. But there are lots of small utilities that do certain tasks faster. For instance, for user accounts, there is useradd, usermod and userdel utilities to add, modify and delete user accounts. 7.Use the man pages for useradd (or just type useradd with no arguments for a simple usage statement) to find out which options are needed to add the following account with all these attributes: login: brianr name: brian rite UID: 5010 GID: nobody shell: /bin/bash Change the passwd for brianr to 'RvRg49()'. Telnet into localhost and login as your new account brianr. What files are present in this new account? Exit from this login. Remove the brianr account using the userdel command. Is the brianr home directory gone? What option would have done this for you? Now wasn't that simpler than using linuxconf?RED HAT 认证学习资料:Chapter 4 Chapter 4 Basic Configuration and Administration Certification Objectives 4.01 Adding, Deleting, and Modifying User Accounts 4.02 The Basic User Environment 4.03 File System Configuration 4.04 Using the Red Hat Package Manager 4.05 Basic Networking 4.06 chkconfig and ntsysv 4.07 Virtual Consoles 4.08 kbdconfig, timeconfig, mouseconfig 4.09 Mounting Floppy Disks and Removable Media 4.10 Sound Cards and the sndconfig Utility linuxconf 2 Deleting a User Account with linuxconf 20 Home Directories and /etc/skel 42 Window Manager Configuration File Locations. 50 File System Types. 55 Validating a Package Signature. 86 To Add and Remove Components. 94 NOTE: Be very careful about which packages you remove from your system. Like most Linux utilities, RPM assumes omniscience, and will silently let you shoot yourself in the foot. Removing the passwd or kernel package would be devastating. 113 Adding Updates, Security Fixes, and Other Items. 114 Verifying One or More Packages. 127 Seeing What Packages Are Installed. 139 Creating and Using Custom RPMs. 157 Building Custom Source and Binary RPMs. 175 Building an RPM from a Tar Archive. 181 The /etc/sysconfig/ Files Used in Network Setup. 221 /etc/sysconfig Files for Clock, Mouse, Static-routes, Keyboard, and PCMCIA.. 224 Setting Up a Network Interface. 227 The Boot Process. 290 The chkconfig Utility. 305 The ntsysv Utility. 311 Between X Display and Virtual Consoles. 323 kbdconfig. 329 timeconfig. 334 mouseconfig. 338 After installation is complete on your Red Hat Linux system, you still have some work to do to make the system functional. User accounts need to be set up, file systems configured, and some packages may need to be added or removed. This chapter will get you started with the basics that every Red Hat Linux administrator should know about their system. At the end of this chapter, you should know how to manage user accounts and environments, configure and mount file systems, use RPM to manage packages, configure PCMCIA, manage system daemons, and configure virtual consoles, keyboards, and mice. CERTIFICATION OBJECTIVE 4.01 Adding, Deleting, and Modifying User Accounts After installation, your system has only a single login account along with the root account. For some installations, you'll want to create more accounts. Even if you're going to be the only user on the system, it's a good idea to create a single, nonprivileged account to do your day-to-day work, and use the root account only for administering the system. Accounts can be added to Red Hat Linux systems using various utilities like vi (manual method), useradd (command line oriented) and the linuxconf utility (text or graphical interface). linuxconf linuxconf can be run in graphical or character mode. If you have already configured X, and are running a graphical desktop, llinuxconf will start in graphical mode. Otherwise, it will start in character mode. In either mode, the instructions are the same. Figure 4-1 shows linuxconf in graphical mode. Figure 4-1: The linuxconf main screen Exercise 4-1 Adding a User with linuxconf To add a user with linuxconf: 1. Run /bin/linuxconf. 2. Open Config ½ User accounts ½ Normal ½ User accounts. (This notation indicates you should open the Config tab, followed by the User accounts tab, then the Normal tab, and, finally, the User accounts tab. This will open the User Accounts form, as shown in Figure 4-2.) If you have more than 15 accounts on the system, linuxconf will present a Filter control screen. You can use this screen to select a smaller range of accounts to view, or just click Accept to view all accounts. 3. Select the Add button. 4. Complete the form (Figure 4-3) and click the Accept button. The only required field is Login Name, but you will most likely want to specify more information for each account. Table 4-1 describes each field. 5. You will be prompted to enter the user's password. The password should be at least six characters (you'll get an error message if it's less than six characters, but linuxconf will allow you to use the password anyway), and should contain a mix of upper- and lowercase letters, numbers, and symbols to keep it from being easily guessed. Enter the password in the Confirmation field to ensure you haven't misspelled it, then choose Accept. 6. When you are done adding users, click Quit to exit linuxconf. Figure4-2: The User Accounts form Figure 4-3: User account creation Field Instructions The Account is enabled Make sure this is checked if you want the user to be able to log in. If you're creating an administrative account that won't be used to log in, (some app needs it to run) uncheck this box. Login name The user logs in with this name. The Login name should only contain alphanumeric characters, and the - and _ characters. In almost all cases, the Login name should not contain uppercase letters. Although a login name can be up to 256 characters, you typically want to keep it to 10 or less, for ease of account maintenance. Examples: nickS, DGcatherine, heatherR, willr. Full name The full name of the user. Example: Dana Gordon. group (opt) The numeric group ID (GID) the user will belong to. By default, Red Hat Linux creates a new group for every new user. If you want all your users to be in the Users group, enter "users" here. Supplementary groups Enter any additional groups you want this user to be a member of. Home directory (opt) By default, Red Hat Linux places new home directories in /home/username. Command interpreter (opt) Enter the name of the shell program this user will use. Red Hat Linux defaults to the Bourne Again Shell (bash). User ID (opt) The user will be assigned the next available User ID (UID), if left blank. In most cases, it's best to leave this blank. Must keep # days If set to a positive number, the user must keep new passwords this many days before being allowed to change it. Must change after # days If set to a positive number, the user must change their password after this many days. Warn # days before expiration If set to a positive number, the user will be warned when logging on this many days before their password expires. Account expire after # days If set to a positive number, the account will be locked after this many days. This is a good setting for temporary logins. Table 1: User Fields Although creating user accounts may seem to be a straightforward process, there are a few things to watch out for: * linuxconf will let you get away with using invalid characters in usernames, such as %, &, *, and !. However, many Linux programs will fail to function with usernames that contain these characters. * If your installation doesn't require each user to have their own unique group ID (GID), assign your users to the Users group. There's rarely a need for each user to have an individual GID, and having most users assigned to the Users group makes system administration easier. However, the reason for the individual group ID system is for security purposes. By default, everyone in the same group will likely have access to each other's files. With every user having a separate GID, file security is heightened. Each user will have to explicitly provide access to their files. * Ask your users to use passwords that are difficult to guess. Spouses' and dogs' names make bad passwords. Several words strung together with numbers or symbols make better passwords, such as "toy+jobs" or "rule%key." These are easy to remember, yet difficult to guess. * Discourage the use of shared accounts, where several people use a single account. Shared accounts are almost always unnecessary, and are easily compromised. * If you'll be using Network File System (NFS), make sure users maintain the same UID across systems. NFS can provide a centralized management of all user accounts across all participating machines. This greatly simplifies account maintenance at the expense of adding both administrative and additional network overhead. Deleting a User Account with linuxconf Removing user accounts is as straightforward as adding them, with a few exceptions. When you remove a user from your system, you'll have to make some choices about how (or if) you will save the files in the user's home directory. linuxconf gives you several choices regarding this decision. Exercise 4-2 Deleting a User Account with linuxconf 1. Run /bin/linuxconf. 2. Select Config ½ User accounts ½ Normal ½ User accounts. This will open the User accounts form. If you have more than 15 accounts on the system, linuxconf will present a Filter control screen. You can use this screen to select a smaller range of accounts to view, or just choose Accept to view all accounts. 3. Select the account to be deleted. 4. Press the del button. 5. Select the appropriate option for the account data (see Table 4-2). 6. Choose the Accept button. Deleting Account Data Option Action Archive the account's data Data stored in the user's home directory is archived in /home/oldaccounts, under the filename username-yyyy-mm-dd-pid.tar.gz,(where username is the name of the deleted user; yyyy, mm, and dd are, respectively, the year, month, and day the account was deleted. pid is the process ID of the linuxconf process that created this file; and .tar.gz indicates this file was tar'd and gzip'd. The user's home directory is then removed. Delete the account's data The user's home directory and all its contents are removed. Leave the account's data in place Nothing is done to the user's home directory and its contents. Table 2: Delete Account Options It is important to note that only files in the deleted user's home directory are processed. Any files owned by the deleted user stored outside the home directory still exist, under the UID of the deleted user. If a new user is created with the old user's UID, the new user owns those files. Exercise 4-3 Modifying a User Account Using linuxconf 1. Run /sbin/linuxconf. 2. Select Config ½ User accounts ½ Normal ½ User accounts. This will open the User Accounts form. If you have more than 15 accounts on the system, linuxconf will present a Filter control screen. You can use this screen to select a smaller range of accounts to view, or just choose Accept to view all accounts. 3. Select the account to be modified. 4. Make the desired modifications to the account. 5. Choose Accept. CERTIFICATION OBJECTIVE 4.02 The Basic User Environment Each user on your Red Hat Linux system has an environment when logged on to the system. The environment defines where a user looks for programs to be executed, what the login prompt looks like, what terminal type is being used, and more. This section explains how default environments are set up. Home Directories and /etc/skel Red Hat Linux makes it easy to run a set of standard templates to propagate to new users' home directories via /etc/skel. Home Directories The home directory is the initial directory in which users are placed when they first log on to a Red Hat Linux system. For most normal users, this will be /home/username, where username is the user's login name. Users typically have write permission in their own home directory, so they're free to read and write their own files there. In Chapter 5, you'll learn how to configure disk quotas, so users don't allocate more than their fair share of disk space. /etc/skel The /etc/skel directory contains default environment files for new accounts. linuxconf copies these files to the home directory when a new account is created. Depending on the software installed, the files included in /etc/skel and their purpose are listed in Table 4-3. Files Purpose .Xdefaultsscreenrc Contains default settings for a few common X applications, if X is installed .bashrc The individual per-interactive-shell startup file .bash_logout Source the commands in this file upon logout .bash_profile The personal initialization file, executed for login shells .kde, .kderc The KDE desktop environment customization, if installed Desktop The GNOME desktop environment customization, if installed Table 3: Files in /etc/skel and Their Purpose As the system administrator, you can edit these files, or place your own files in /etc/skel. When new users are created, these files will be propagated to the new users' home directories. Additional entries are placed there by various programs during installation, such as emacs and secure shell. Window Manager Configuration File Locations Red Hat Linux comes with several window managers. You will at some point want to configure one or more of them for use on your system. Window manager configuration files are stored in /etc/X11/, where is the name of the window manager. Within the window manager subdirectory, there is usually a file named system., which contains default behavior for the window manager. CERTIFICATION OBJECTIVE 4.03 File System Configuration There are as many, if not more, file system types as there are operating systems. Red Hat Linux can understand many of these formats. File System Types At the heart of every R。