1. Trang chủ
  2. » Thể loại khác

Tài Liệu - Võ Tấn Dũng (votandung) Unit9 Linux ITC

27 107 0

Đ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

Nội dung

Information Technology College of HoChiMinh city Faculty of Information Technology Course: Fundamentals of Linux OS Unit System Processes Management Lecturer: Võ Tấn Dũng votandung@yahoo.com http://sites.google.com/site/votandungsg/ System Process Overview • Each task you perform in the Linux environment starts a process • Each process is assigned a unique process identification number (PID), which is used by the system to identify the process • There are five types of processes on a Linux system: 1) Daemon 2) Parent 3) Child 4) Orphan 5) Zombie or defunct VÕ TẤN DŨNG Processes and PIDs • Use the ps command to list the processes currently running on the system The output of this command will display the PID number and the command associated with it Many times a PID number is needed for use with the kill command Command Format ps [-options] • Options -e : Print information about every process on the system -f : Generate a full listing (Refer to the man pages for a description of the headings displayed.) Because of the number of processes usually running on a system, it is useful to pipe the ps -ef command to more so that the output can be read a page at a time VÕ TẤN DŨNG Displaying a Full Listing of All Processes VÕ TẤN DŨNG Displaying a Full Listing of All Processes (cont.) • This table describes the column headings of the previous example VÕ TẤN DŨNG Some more options of ps command Command Format • options : – – – – – a x u l w ps [-options] list all process on the same terminal all process without control tty select by effective user id Long-format Wide output VÕ TẤN DŨNG Example: $ ps PIDTTY TIME CMD 728pts/3 00:00:00 bash 1010pts/3 00:00:00 ps $ ps -auw USER PID %CPU %MEM root 728 0.0 0.6 root 1161 0.0 0.3 VSZ RSS 3528 1604 3548 860 TTY pts/3 pts/3 STAT S R START 21:08 22:29 TIME 0:00 0:00 COMMAND /bin/bash ps auw • status : – – – – R S Z W running (runable) suspend (sleeping) stopped (zombie process) not enough memory for process VÕ TẤN DŨNG Example: • To check if the process is in the background : #ps –aux | grep find • Or using jobs command: #jobs VÕ TẤN DŨNG top command • top command provides an ongoing look at processor activity in real time • Options : -d delay specifies the delay between screen updates -p [pid] monitor only processes with given process id -c display command line instead of the command name only • Some hot keys used with top command: q quit Spacebar immediately updates the display K kill a process VÕ TẤN DŨNG Searching for a Specific Process • A quicker way of determining the correct PID is to pipe the output of the ps command through grep, searching for the specific process you want to terminate • A quicker way of determining the correct PID is to pipe the output of the ps command through grep, searching for the specific process you want to terminate VÕ TẤN DŨNG Run a job in the background • To run a job in the background, type the command followed by an ampersand (&) The number returned in brackets is the job ID number • An example of a time-consuming job that could be run in the background is searching a large directory structure with the find command • For example: VÕ TẤN DŨNG Run a job in the background (cont.) •in previous example, each argument has the following meaning: •The responses displayed by the system have the following meaning: VÕ TẤN DŨNG Some examples VÕ TẤN DŨNG Some examples (cont.) VÕ TẤN DŨNG Signals • Signals: There are currently 33 signals defined in the Linux operating system (see /usr/include/signum.h) Each signal is associated with a number and a name Signals are used to terminate, suspend, and continue processes Information on the different signals can be found by using the following command: $ man -S signal • A process that is not responding can sometimes be terminated by using Ctrl-C This sends an interrupt (INT) signal to the process, terminating it and any child processes it might have spawned VÕ TẤN DŨNG kill command • The command kill sends the specified signal to the specified process or process group If no signal is specified, the TERM signal (15) is sent The TERM signal will kill processes which not catch this signal For other processes, it may be necessary to use the KILL (9) signal, since this signal cannot be caught kill [-s signal|-p] pid kill -l [signal] Using kill –l to list all signal names 1) SIGHUP 2) SIGINT 3) SIGQUIT 5) SIGTRAP 6) SIGABRT 7) SIGBUS 9) SIGKILL 10) SIGUSR1 11) SIGSEGV 13) SIGPIPE 14) SIGALRM 15) SIGTERM 18) SIGCONT 19) SIGSTOP 20) SIGTSTP 4) SIGILL 8) SIGFPE 12) SIGUSR2 17) SIGCHLD 21) SIGTTIN VÕ TẤN DŨNG killall command • killall sends a signal to all processes running any of the specified commands If no signal name is specified, SIGTERM is sent • Signals can be specified either by name (e.g -HUP or -SIGHUP ) or by number (e.g -1) or by option -s • Example: # killal -HUP syslogd # killall -9 man VÕ TẤN DŨNG Terminating a Process • You would: Type ps to find out the PID(s) for the process(es) Type kill followed by the PID(s) • If you use the kill command without specifying a signal, signal 15 (SIGTERM) is sent to the process with the specified PID number This usually causes the process to terminate VÕ TẤN DŨNG Finding and Terminating a Process by User •The ps -u command can be used either with a login name or a UID number ps -u login-ID •A user can only terminate his or her own processes, but the superuser can terminate any process running on the system •If there are multiple windows open on a user’s desktop, the output of the ps command will show pts/# under the TTY heading for every window open •A pts (pseudoterminal) is the device name given to windows and remote login sessions VÕ TẤN DŨNG Finding and Terminating a Process by User (cont.) VÕ TẤN DŨNG Force to terminate a process • If you need to forcibly terminate a process, you can append the -9 option to the kill command kill -9 PID# VÕ TẤN DŨNG Abort a background job • To abort a background job, use the specific job number as the argument to the kill command VÕ TẤN DŨNG pkill command • The pkill command works exactly like the pgrep command, except that it terminates the matching process or processes with a kill signal VÕ TẤN DŨNG Tracking your system • w: show who is logged on and what they are doing • free: display information about free and used memory on the system • uptime: tell how long the system has been running • pstree: display a tree of processes • pgrep, pkill: look up or signal processes based on name and other • nice, renice, snice: change the priority of the process VÕ TẤN DŨNG END OF UNIT • remember to your homework (see http://sites.google.com/site/votandungsg/) VÕ TẤN DŨNG ... have the following meaning: VÕ TẤN DŨNG Some examples VÕ TẤN DŨNG Some examples (cont.) VÕ TẤN DŨNG Signals • Signals: There are currently 33 signals defined in the Linux operating system (see... Signals can be specified either by name (e.g -HUP or -SIGHUP ) or by number (e.g -1 ) or by option -s • Example: # killal -HUP syslogd # killall -9 man VÕ TẤN DŨNG Terminating a Process • You would:... system, it is useful to pipe the ps -ef command to more so that the output can be read a page at a time VÕ TẤN DŨNG Displaying a Full Listing of All Processes VÕ TẤN DŨNG Displaying a Full Listing

Ngày đăng: 15/12/2017, 16:53

TỪ KHÓA LIÊN QUAN