Linux all in one desk reference for dummies phần 6 pot

75 431 0
Linux all in one desk reference for dummies phần 6 pot

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Chapter 1: Learning Basic System Administration In This Chapter ߜ Introducing the GUI sysadmin tools ߜ Becoming root ߜ Understanding the system startup process ߜ Taking stock of the system configuration files ߜ Viewing system information through the /proc file system ߜ Monitoring system performance ߜ Managing devices ߜ Scheduling jobs S ystem administration or sysadmin refers to whatever has to be done to keep a computer system up and running; the system administrator (also called the sysadmin) is whoever is in charge of taking care of these tasks. If you’re running Linux at home or in a small office, you’re most likely the system administrator for your systems. Or maybe you’re the system admin- istrator for a whole LAN full of Linux systems. No matter. In this chapter, I introduce you to basic system administration procedures and show you how to perform some common tasks. Each Linux distribution comes with quite a few graphical tools for perform- ing specific system administration tasks. I introduce you to some of these GUI tools in this chapter and describe some of them in greater detail in the other chapters of this minibook. Taking Stock of System Administration Tasks So what are system administration tasks? My off-the-cuff reply is anything you have to do to keep the system running well. More accurately, though, a system administrator’s duties include the following: TEAM LinG - Live, Informative, Non-cost and Genuine ! Taking Stock of System Administration Tasks 350 ✦ Adding and removing user accounts. You have to add new user accounts and remove unnecessary user accounts. If a user forgets the password, you have to change the password. ✦ Managing the printing system. You have to turn the print queue on or off, check the print queue’s status, and delete print jobs if necessary. ✦ Installing, configuring, and upgrading the operating system and vari- ous utilities. You have to install or upgrade parts of the Linux operating system and other software that are part of the operating system. ✦ Installing new software. You have to install software that comes in vari- ous package formats such as RPM or DEB. You also have to download and unpack software that comes in source-code form — and then build executable programs from the source code. ✦ Managing hardware. Sometimes, you have to add new hardware and install drivers so the devices work properly. ✦ Making backups. You have to back up files, either in a Zip drive or on tape (if you have a tape drive). ✦ Mounting and unmounting file systems. When you want to access the files on a CD-ROM, for example, you have to mount that CD-ROM’s file system on one of the directories in your Linux file system. You also have to mount floppy disks, in both Linux format and DOS format. ✦ Automating tasks. You have to schedule Linux tasks to take place auto- matically (at specific times) or periodically (at regular intervals). ✦ Monitoring the system’s performance. You may want to keep an eye on system performance to see where the processor is spending most of its time, and to see the amount of free and used memory in the system. ✦ Starting and shutting down the system. Although starting the system typically involves nothing more than powering up the PC, you do have to take some care when you want to shut down your Linux system. If your system is set up for a graphical login screen, you can perform the shutdown operation by selecting a menu item from the login screen. Otherwise, use the shutdown command to stop all programs before turning off your PC’s power switch. ✦ Monitoring network status. If you have a network presence (whether a LAN, a DSL line, or cable modem connection), you may want to check the status of various network interfaces and make sure your network connection is up and running. ✦ Setting up host and network security. You have to make sure that system files are protected and that your system can defend itself against attacks over the network. ✦ Monitoring security. You have to keep an eye on any intrusions, usually by checking the log files. TEAM LinG - Live, Informative, Non-cost and Genuine ! Book V Chapter 1 Learning Basic System Administration Introducing Some GUI Sysadmin Tools 351 That’s a long list of tasks! I don’t cover all of them in this chapter, but the rest of the minibook describes most of these tasks. Here, I focus on some of the basics by introducing you to some GUI tools, explaining how to become root (the superuser), describing the system configuration files, and showing you how to monitor system performance, manage devices, and set up peri- odic jobs. Introducing Some GUI Sysadmin Tools Each Linux distribution comes with GUI tools for performing system adminis- tration tasks. The GUI tools prompt you for input and then run the necessary Linux commands to perform the task. In the following sections, I briefly intro- duce the GUI sysadmin tools in Debian, Fedora Core, SUSE, and Xandros. GUI sysadmin tools in Debian Debian does not have too many GUI tools for performing sysadmin tasks. You can, however, use some of the KDE GUI tools to take care of some sysad- min chores. Table 1-1 lists some common tasks and the menu selection you use to start the GUI tool that enables you to perform that task. Table 1-1 Performing Sysadmin Tasks with GUI Tools in Debian To Do This Select the Following the KDE Desktop Add or remove software Main Menu➪System➪Package Manager Change password Main Menu➪Settings➪Change Password Configure KDE desktop Main Menu➪Settings➪Control Center Find files Main Menu➪Find Files Format floppy Main Menu➪Utilities➪Floppy Formatter Manage printers Main Menu➪System➪Printers Manage user accounts Main Menu➪System➪User Manager Monitor system performance Main Menu➪System➪System Monitor Schedule a task Main Menu➪System➪Task Scheduler View system logs Main Menu➪System➪System Log GUI sysadmin tools in Fedora Core Fedora Core comes with a set of GUI system configuration tools that can ease the burden of performing typical sysadmin chores. Table 1-2 briefly summarizes the menu selections you use to start a GUI tool for a specific task. TEAM LinG - Live, Informative, Non-cost and Genuine ! Introducing Some GUI Sysadmin Tools 352 Table 1-2 Starting GUI Sysadmin Tools in Fedora Core To Configure or Manage This Start GUI Tool by Selecting This Date and time Main Menu➪System Settings➪Date&Time Disks and DVD/CD-ROM Main Menu➪System Tools➪Disk Management Display settings Main Menu➪System Settings➪Display Firewall settings Main Menu➪System Settings➪Security Level Hardware Main Menu➪System Tools➪Hardware Browser Internet connection Main Menu➪System Tools➪Internet Configuration Wizard Network Main Menu➪System Settings➪Network Preferences such as desktop Main Menu➪Preferences and password Printer Main Menu➪System Settings➪Printing root password Main Menu➪System Settings➪Root Password Servers Main Menu➪System Settings➪Server Settings Software Main Menu➪System Settings➪Add/Remove Application System logs Main Menu➪System Tools➪System Logs System performance Main Menu➪System Tools➪System Monitor User accounts Main Menu➪System Settings➪Users and Groups GUI sysadmin tools in Knoppix Knoppix is a Live CD distribution that you can use either to try out Linux or as a tool to fix problems in an existing Linux system. As such, Knoppix comes with several GUI tools that you can use for system administration tasks. Table 1-3 summarizes some of the GUI tools in Knoppix. Table 1-3 Using GUI tools for Sysadmin Tasks in Knoppix To Do This Select This from the Knoppix GUI Desktop Configure desktop Main Menu➪Settings➪Desktop Settings Wizard Configure KDE Main Menu➪Settings➪Control Center Configure network Main Menu➪KNOPPIX➪Network/Internet➪ Network card configuration Configure printer Main Menu➪KNOPPIX➪Configure➪Configure printer(s) Find Files Main Menu➪Find Files TEAM LinG - Live, Informative, Non-cost and Genuine ! Book V Chapter 1 Learning Basic System Administration Introducing Some GUI Sysadmin Tools 353 To Do This Select This from the Knoppix GUI Desktop Manage disk partitions (for Main Menu➪System➪QTParted troubleshooting existing Linux installations) Open a terminal window with Main Menu➪KNOPPIX➪Root Shell root permission Start Samba Server Main Menu➪KNOPPIX➪Services➪Start Samba Server Start SSH server Main Menu➪KNOPPIX➪Services➪Start SSH Server GUI sysadmin tools in SUSE In SUSE, select Main Menu➪System➪YaST to start your system administra- tion tasks in the YaST Control Center. Figure 1-1 shows the YaST Control Center window. The left side of the YaST Control Center shows icons for the categories of tasks you can perform. The right-hand side shows icons for specific tasks in the currently selected category. When you click an icon in the right-hand side of the YaST Control Center, a new YaST window appears and enables you to perform that task. Figure 1-1: YaST Control Center is your starting point for many sysadmin tasks in SUSE. TEAM LinG - Live, Informative, Non-cost and Genuine ! Introducing Some GUI Sysadmin Tools 354 Table 1-4 summarizes the tasks for each of the category icons you see in the left side of the YaST Control Center. As you can see from the entries in the second column of Table 1-4, YaST Control Center is truly one-stop shopping for all of your sysadmin chores. Table 1-4 Tasks by Category in the YaST Control Center This Category Enables You to Configure/Manage the Following Software Online Update; Install and Remove Software; Change Source of Installation; Installation into Directory; Patch CD Update; System Update Hardware CD-ROM Drives; Disk Controllers; Graphics Card and Monitor; Hardware Information; IDE DMA Mode; Joystick; Printer; Scanner; Select Mouse Model; Sound; TV Card System /etc/sysconfig Editor; Boot Loader Configuration; Choose Language; Create a Boot, Rescue, or Module Floppy; Date and Time; LVM; Partitioner; Power Management; Powertweak Configuration; Profile Manager; Restore System; Runlevel Editor; Select Keyboard Layout; System Backup Network Devices DSL; Fax; ISDN; Modem; Network Card; Phone Answering Machine Network Services DHCP Server; DNS Server; DNS Host and Name; HTTP Server; Host Names; Kerberos Client; LDAP Client; Mail Transfer Agent; NFS Client; NFS Server; NIS Client; NIS Server; NTP Client; Network Services (inetd); Proxy; Remote Administration; Routing; SLP Browser; Samba Client; Samba Server; TFTP Server Security and Users Edit and create groups; Edit and create users; Firewall; Security settings Misc Autoinstallation; Load Vendor Driver CD; Post a Support Query; View Start-up Log; View System Log GUI sysadmin tools in Xandros Xandros is designed to be a desktop operating system, and as such, every- thing is easily accessible from the desktop. For most sysadmin tasks, you start at the Xandros Control Center — select Main Menu➪Control Center to get there. (Figure 1-2 shows you what you find when you do get there.) As you can see, the left-hand side of the window shows a tree menu of task categories. You can click the plus sign next to a category to view the subcat- egories. When you click a specific task, the right-hand side of the window displays the GUI through which you can perform that task. For some tasks, such as mounting file systems or adding printers, you can open the Xandros File Manager as a system administrator by selecting Main Menu➪Applications➪System➪Administrator Tools➪Xandros File Manager (Administrator). Figure 1-3 shows the Xandros File Manager window from which you can perform some sysadmin tasks. TEAM LinG - Live, Informative, Non-cost and Genuine ! Book V Chapter 1 Learning Basic System Administration How to Become root 355 How to Become root You have to log in as root to perform the system administration tasks. The root user is the superuser and the only account with all the privileges needed to do anything in the system. Figure 1-3: For some sysadmin tasks, use the Xandros File Manager. Figure 1-2: You can perform many sysadmin tasks from the Xandros Control Center. TEAM LinG - Live, Informative, Non-cost and Genuine ! How to Become root 356 Common wisdom says you should not normally log in as root. When you’re root, one misstep, and you can easily delete all the files — especially when you’re typing commands. Take, for example, the command rm *.html that you may type to delete all files that have the .html extension. What if you accidentally press the spacebar after the asterisk (*)? The shell takes the command to be rm * .html and — because * matches any filename — deletes everything in the current directory. Seems implausible until it hap- pens to you! Using the su - command If you’re logged in as a normal user, how do you do any system administra- tion chores? Well, you become root for the time being. If you’re working at a terminal window or console, type su - Then enter the root password in response to the prompt. From this point on, you’re root. Do whatever you have to do. To return to your usual self, type exit That’s it! It’s that easy. By the way, Knoppix does not have any root password, so you can become root by simply typing su - at the shell prompt in a terminal window. Becoming root for the GUI utilities Most Linux distributions include GUI utilities to perform system administra- tion chores. If you use any of these GUI utilities to perform a task that requires you to be root, the utility typically pops up a dialog box that prompts you for the root password, as shown in Figure 1-4. Just type the password and press Enter. If you don’t want to use the utility, click Cancel. Figure 1-4: Type the root password and press Enter to gain root privileges. TEAM LinG - Live, Informative, Non-cost and Genuine ! Book V Chapter 1 Learning Basic System Administration How to Become root 357 Recovering from a forgotten root password To perform system administration tasks, you have to know the root pass- word. What happens if you forget the root password? Not to worry: Just reboot the PC and you can reset the root password by following these steps: 1. Reboot the PC (select Reboot as you log out of the GUI screen) or power up as usual. Soon you see the graphical GRUB boot loader screen that shows the names of the operating systems you can boot. If your system runs the LILO boot loader, press Ctrl+X and at the boot: prompt, type linux single and press Enter. Then proceed to step 4. 2. If you have more than one operating system installed, use the arrow key to select Linux as your operating system. Then press the A key. GRUB prompts you for commands to add to its default boot command. 3. Press the spacebar, type the following, and then press Enter: single Linux starts up as usual but runs in a single-user mode that does not require you to log in. After Linux starts, you see the following command- line prompt that ends with a hash mark ( #), similar to the following: sh-2.05b# 4. Type the passwd command to change the root password as follows: sh-2.05b# passwd Changing password for user root. New password: 5. Type the new root password that you want to use (it doesn’t appear on-screen) and then press Enter. Linux asks for the password again, like this: Retype new password: 6. Type the password again, and press Enter. If you enter the same password both times, the passwd command changes the root password. 7. Now type reboot to reboot the PC. After Linux starts, it displays the familiar login screen. Now you can log in as root with the new password. TEAM LinG - Live, Informative, Non-cost and Genuine ! Understanding How Linux Boots 358 Make sure that your Linux PC is physically secure. As these steps show, anyone who can physically access your Linux PC can simply reboot, set a new root password, and do whatever he or she wants with the system. Another way to protect against resetting the password is to set a GRUB pass- word, which causes GRUB to require a valid password before it boots Linux. Of course, you must then remember to enter the GRUB password every time you boot your system! Understanding How Linux Boots Knowing the sequence in which Linux starts processes as it boots is impor- tant. You can use this knowledge to start and stop services, such as the Web server and Network File System (NFS). The next few sections provide you with an overview of how Linux boots and starts the initial set of processes. These sections also familiarize you with the shell scripts that start various services on a Linux system. Understanding the init process When Linux boots, it loads and runs the core operating system program from the hard drive. The core operating system is designed to run other pro- grams. A process named init starts the initial set of processes on your Linux system. To see the processes currently running on the system, type ps ax | more You get an output listing that starts off like this: PID TTY STAT TIME COMMAND 1 ? S 0:22 init [2] The first column, with the heading PID, shows a number for each process. PID stands for process ID (identification) — a sequential number assigned by the Linux kernel. The first entry in the process list, with a process ID (PID) of 1, is the init process. It’s the first process, and it starts all other processes in your Linux system. That’s why init is sometimes referred to as the “mother of all processes.” What the init process starts depends on the following: ✦ The run level, an identifier that identifies a system configuration in which only a selected group of processes can exist. ✦ The contents of the /etc/inittab file, a text file that specifies which processes to start at different run levels. TEAM LinG - Live, Informative, Non-cost and Genuine ! [...]... run level 2, type the following command: ls -l /etc/rc2.d TEAM LinG - Live, Informative, Non-cost and Genuine ! Understanding How Linux Boots 363 Manually starting and stopping servers In Linux, the server startup scripts reside in the /etc/init.d directory You can manually invoke scripts in this directory to start, stop, or restart specific processes — usually servers For example, to stop the FTP... you find the following lines near the beginning of the file: # Boot-time system configuration/initialization script si::sysinit:/etc/init.d/rcS The first line is a comment line The second line causes init to run the /etc/init.d/rcS script — the first Linux startup script that init runs in a Debian system The rcS script performs many initialization tasks, such as mounting the file systems, setting the... /etc/inittab file, controls which processes init starts in Linux The default run level is 2 in Debian and Xandros In Fedora Core and SUSE, run level 3 is used for textmode login screens and 5 for the graphical login screen You can change the default run level by editing a line in the /etc/inittab file To check the current run level, type the following command in a terminal window: /sbin/runlevel In Debian,... fdiv_bug line indicates whether this particular Pentium has the bug (Fortunately, my PC’s processor does not.) The last line in the /proc/cpuinfo file shows the BogoMips for the processor, as computed by the Linux kernel when it boots BogoMips is something that Linux uses internally to time-delay loops TEAM LinG - Live, Informative, Non-cost and Genuine ! Book V Chapter 1 Learning Basic System Administration... time spent waiting for input or output (I/O) In the vmstat utility’s output, high values in the si and so fields indicate too much swapping (Swapping refers to the copying of information between physical memory and the virtual memory on the hard drive.) High numbers in the bi and bo fields indicate too much disk activity Checking disk performance and disk usage Linux comes with the /sbin/hdparm program... appears in the listing as a huge file, no single physical file is occupying that much space on your hard drive — so don’t try to remove the file to reclaim disk space Several files and directories in /proc contain interesting information about your Linux PC The /proc/cpuinfo file, for example, lists the key characteristics of your system, such as processor type and floating-point processor information... cache si so bi bo in cs 0 0 31324 40 16 18 568 1 360 04 1 1 17 16 8 110 0 1 31324 2520 15348 13 969 2 0 0 7798 199 1157 377 1 0 31324 1584 129 36 141480 0 19 5784 105 1099 437 2 0 31324 1928 13004 1371 36 7 0 15 86 138 1104 561 3 1 31324 1484 13148 132 064 0 0 1 260 51 1080 427 0 0 31324 1804 13240 1279 76 0 0 11 26 46 1082 782 0 0 31324 1900 13240 1279 76 0 0 0 0 1010 211 0 0 31324 19 16 13248 1279 76 0 0 0 10 1015... Scheduling recurring jobs Although at is good for running commands at a specific time, it’s not useful for running a program automatically at repeated intervals You have to use crontab to schedule such recurring jobs — for example, if you want to back up your files to tape at midnight every evening You schedule recurring jobs by placing job information in a file with a specific format and submitting this... schedule cron jobs using crontab: TEAM LinG - Live, Informative, Non-cost and Genuine ! Learning Basic System Administration atq Book V Chapter 1 384 Scheduling Jobs in Linux ✦ /etc/cron.allow contains the names of the users who may submit jobs using the crontab command ✦ /etc/cron.deny contains the names of users not allowed to submit jobs using the crontab command If the /etc/cron.allow file exists,... Following insmod Inserts a module into the kernel rmmod Removes a module from the kernel depmod Determines interdependencies between modules TEAM LinG - Live, Informative, Non-cost and Genuine ! Managing Loadable Driver Modules 379 Does the Following ksyms Displays a list of symbols along with the name of the module that defined the symbol lsmod Lists all currently loaded modules modinfo Displays information . jobs. Introducing Some GUI Sysadmin Tools Each Linux distribution comes with GUI tools for performing system adminis- tration tasks. The GUI tools prompt you for input and then run the necessary Linux. Main Menu➪Settings➪Change Password Configure KDE desktop Main Menu➪Settings➪Control Center Find files Main Menu➪Find Files Format floppy Main Menu➪Utilities➪Floppy Formatter Manage printers Main. Settings➪Network Preferences such as desktop Main Menu➪Preferences and password Printer Main Menu➪System Settings➪Printing root password Main Menu➪System Settings➪Root Password Servers Main Menu➪System Settings➪Server

Ngày đăng: 23/07/2014, 23:20