[ Pobierz całość w formacie PDF ]
.The limits shown in this exampleare known as soft limits.To view the shell s hard limits, log in as the root operator, and usethe -a limit option (use -Ha for bash or ksh s ulimit command), for example:$ suPassword:# limit -hcputime unlimitedfilesize unlimiteddatasize unlimitedstacksize 8192 kbytescoredumpsize unlimitedmemoryuse unlimiteddescriptors 256memorylocked unlimitedmaxproc 256As you can see, viewing the limits as the root operator in the tcsh shell shows a much differentsituation.This is another good reason not to run as the root operator! As a sysadmin, you canuse these settings to limit the amount of memory or number of processes available to eachuser.This is extremely handy if you have a number of people working on your computer atthe same time, and you want to conserve system memory.For using Linux on a standalonecomputer under your normal login and working conditions, you ll find the default limitsquite reasonable.Reclaiming Memory with the kill CommandAs a desperate measure if you need to quickly reclaim memory, you can stop runningprograms by using the kill command.In order to kill a specific program, you should use theps command to list current running processes, and then stop any or all of them with the killcommand.By default, the ps command lists processes you own and which you can kill, for2 0example:# psPID TTY STAT TIME COMMAND367 p0 S 0:00 bash581 p0 S 0:01 rxvt582 p1 S 0:00 (bash)747 p0 S 0:00 (applix)809 p0 S 0:18 netscape index.html810 p0 S 0:00 (dns helper)945 p0 R 0:00 ps 304 Hour 20The ps command will list the currently running programs and the program s process number,or PID.You can use this information to kill a process with# kill -9 809However, if you need to reclaim memory efficiently, you should use the ps command s -moption, which also lists the memory usage of each process, for example:# ps -mPID TTY MAJFLT MINFLT TRS DRS SIZE SWAP RSS SHRD LIB DT COMMAND747 p0 0 3 16 208 364 140 224 224 0 0 (applix)582 p1 151 274 124 184 436 128 308 268 0 10 (bash)959 p0 89 20 28 376 404 0 404 320 0 21 ps -m367 p0 305 826 220 316 600 64 536 428 0 27 bash810 p0 313 38 164 696 968 108 860 596 0 47 (dns helpe581 p0 212 508 28 960 1280 292 988 304 0 171 rxvt809 p0 2615 1205 3900 3692 8684 1092 7592 4644 0 699 netscapeBy using this information, you can see that if you want to reclaim the most memory, youshould stop the Netscape Web browser, as it is using nearly 9MB of system memory.Although you wouldn t normally use the kill command to stop programs, the killcommand can be helpful to stop runaway, or nonresponsive, programs.The kill commandworks by sending a signal to the Linux kernel, along with the PID, so the kernel can act onthe process.There are various signals you can use, although, as I ve pointed out, the -9, orSIGKILL option is the most abrupt and drastic.You can see a list of different signals by usingthe kill command s -l option, for example:# kill -l1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL5) SIGTRAP 6) SIGIOT 7) SIGBUS 8) SIGFPE9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR213) SIGPIPE 14) SIGALRM 15) SIGTERM 17) SIGCHLD18) SIGCONT 19) SIGSTOP 20) SIGTSTP 21) SIGTTIN22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO30) SIGPWRFor more details on these signals, and the kill command, see its manual page.The ps command has nearly two dozen command-line options, and you can also list allrunning processes.See the ps manual page for more information.You can also use the topcommand, discussed next, to find and kill processes.Getting System Load Information with thetop and xload CommandsThe top command, found under the /usr/bin directory, is a system monitor that displaysstatistical information about how Linux is currently handling your memory, swap file, andprocesses.The top program also shows how long your system has been running, the status2 0 Basic System Administration 305of your CPU, the size of each process, and more.You ll typically use the top command byrunning it on a spare console, or separate X11 terminal window (see Figure 20.1).Figure 20.1The top commandprovides an ongoingdisplay of your system.The top command also has a number of interactive controls, including a help screen, accessedwith the question mark or the H key.You can also toggle various modes of the display, suchas listing processes by memory usage or limiting the number of processes displayed.This canbe helpful if you would like to monitor only the top five processes that require the greatestamount of your system s memory, and it can help you diagnose problems if your computerstarts unusual disk or swap file activity.You can also use top to interactively kill processes, using the K key, or change a process spriority (how much time the CPU devotes to a task) with the R key.The top program has19 different interactive commands, and you can customize its display by adding or removingdifferent information fields and lengthening or shortening the number of processes.See its2 0manual page for more information.The xload command, used under X11, provides a running graph of your system s load,instead of the top command s statistics.System loads vary from computer to computer, butyou can generally tell when your system is overloaded by inordinate disk activity, as processesare swapped back and forth from your swap file.The xload command can help give you avisual warning if you re running too many programs, and may be especially helpful if you rerunning X11 on a 8MB or 16MB Linux system.The xload command has eight different command-line options, and you can customize thecolor of the moving graphic, scale lines, or background. 306 Hour 20Determining How Long Linux Has Been Runningwith the uptime and w CommandsTheuptime command shows you how long Linux has been running, how many users are on,and three system load averages, for example:# uptime12:44am up 8:16, 3 users, load average: 0.11, 0.10, 0.04If this is too little information for you, try the w command, which first shows the sameinformation as the uptime command, and then lists what currently logged-in users are doing:# w12:48am up 8:20, 3 users, load average: 0.14, 0.09, 0.05USER TTY FROM LOGIN@ IDLE JCPU PCPU WHATbball ttyp0 localhost.locald 9:47pm 15.00s 0.38s 0.16s bashbball ttyp2 localhost.locald 12:48am 0.00s 0.16s 0.08s wThe w command gives a little more information, and it is especially helpful if you would liketo monitor a busy system with a number of users.Getting Network and Mail Information with thepppstats and mailstat CommandsThe pppstats command, found under the /usr/sbin directory, will give you a runningstatistical display on the status and activity of your PPP connection.The information issimilar to the output of the ifconfig command [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • necian.htw.pl