Home

LPI Linux Certification in a Nutshell Part 9

LPI Linux Certification in a Nutshell - novelonlinefull.com

You’re read light novel LPI Linux Certification in a Nutshell Part 9 online at NovelOnlineFull.com. Please use the follow button to get notification about the latest chapter next time when you visit NovelOnlineFull.com. Use F11 button to read novel in full-screen(PC only). Drop by anytime you want to read free – fast – latest novel. It’s great if you could leave a comment, share your opinion about the new chapters, new novel with others on the internet. We’ll do our best to bring you the finest, latest novel everyday. Enjoy

Name ps Syntax ps[options]

Description This command generates a one-time snapshot of the current processes on standard output.

Frequently used options -a Show processes that are owned by other users and attached to a terminal. Normally, only the current user's processes are shown.

-f "Full-format" listing. This option prints command arguments in addition to the command itself.

-l Long format, which includes priority, parent PID, and other information.

-u User format, which includes usernames and the start time of processes.

-w Wide output format, used to eliminate the default output line truncation. Specify it twice (-ww) for unlimited width.

-x Include processes without controlling terminals. Often needed to see daemon processes and others not started from a terminal session.

-C cmd cmd Display instances of command name cmd cmd.

-U user user Display processes owned by username user user.

Examples Simply entering the ps ps command with no options will yield a brief list of processes owned by you and attached to your terminal: command with no options will yield a brief list of processes owned by you and attached to your terminal: $ps Use the -a, -u -a, -u, and -x -x options to include processes owned by others and not attached to terminals as well as to display them in the "user" mode. The command is valid with or without the dash: options to include processes owned by others and not attached to terminals as well as to display them in the "user" mode. The command is valid with or without the dash: $ps-aux $psaux In this case, the dash is optional. However, certain ps ps options require the dash. (See the manpage for details.) options require the dash. (See the manpage for details.) If you are interested in finding process information on a particular command, use the -C -C option. This command displays all web server processes: option. This command displays all web server processes: $psu-Chttpd You'll note that the -C -C option option requires requires the dash, but the the dash, but the u u option won't work with it if a dash is included. This confusion exists because the option won't work with it if a dash is included. This confusion exists because the ps ps command as implemented on Linux understands options in three differing forms: command as implemented on Linux understands options in three differing forms: Unix98 options These may be grouped and must be preceded by a dash.

BSD options These may be grouped and must not not be used with a dash. be used with a dash.

GNU long options These options are preceded by two dashes.NoteThe Linux ps ps tries to be compatible with tries to be compatible with ps ps from various other systems. How it interprets various command-line options, which determines how compatible it is with other versions of from various other systems. How it interprets various command-line options, which determines how compatible it is with other versions of ps ps, can be controlled by setting I_WANT_A_BROKEN_PS I_WANT_A_BROKEN_PS, PS_PERSONALITY PS_PERSONALITY, and various other environment variables. See the ps ps manpage for details. manpage for details.

All of these option types may be freely intermixed. Instead of the -C -C option, you may wish to use option, you may wish to use ps ps with other options that you usually use and pipe the output to with other options that you usually use and pipe the output to grep grep, searching for process names, PIDs, or anything else you know about the process: $psaux|grephttpd In this case, the result would be the same list of httpd httpd servers, as well as the servers, as well as the grep grep command itself. command itself.

Name pstree Syntax pstree[options][pid|user]

Description This command displays a hierarchical list of processes in a tree format. pstree pstree is very handy for understanding how parent/child process relationships are set up. is very handy for understanding how parent/child process relationships are set up.

If the PID is specified, the displayed tree is rooted at that process. Otherwise, it is rooted at the init init process, which has PID 1. If process, which has PID 1. If user user (a valid username) is specified, trees for all processes owned by (a valid username) is specified, trees for all processes owned by user user are shown. The tree is represented using characters that appear as lines, such as are shown. The tree is represented using characters that appear as lines, such as | | for vertical lines and for vertical lines and + + for intersections (VT100 line-drawing characters, displayed as solid lines by most terminals, are optional). The output looks similar to this: for intersections (VT100 line-drawing characters, displayed as solid lines by most terminals, are optional). The output looks similar to this: httpd-+-httpd |-httpd |-httpd |-httpd '-httpd By default, visually identical branches of the tree are merged to reduce output. Merged lines are preceded by a count indicating the actual number of similar processes. The preceding example is normally displayed on a single line: httpd---5*[httpd]

This behavior can be turned off with the -c -c option. option.

Frequently used options -a Display command-line arguments used to launch processes.

-c Disable the compaction of identical subtrees.

-G Use the VT100 line-drawing characters instead of plain characters to display the tree. This yields a much more pleasing display but may not be appropriate for printing or paging programs.

-h Highlight the ancestry of the current process (usually the sh.e.l.l). The terminal must support highlighting for this option to be meaningful.

-n The default sort order for processes with the same parent is alphanumerically by name. This option changes this behavior to a numeric sort by PID.

-p Include PIDs in the output.

Example Display a process tree including PIDs: #pstree-p init(1)-+-atd(468) |-bdflush(5) |-crond(454) |-httpd(440)-+-httpd(450) ||-httpd(451) ||-httpd(452) ||-httpd(453) ||-httpd(455) ||-httpd(456) ||-httpd(457) |'-httpd(458) |-keventd(2) |-kjournald(7) |-klogd(335) |-ksoftirqd_CPU0(3) |-kswapd(4) |-kupdated(6) |-login(475)---bash(478)---pstree(518) |-sendmail(420) |-sshd(385) |-syslogd(330) '-xinetd(402)

Name top Syntax top[options]

Description The top top command offers output similar to command offers output similar to ps ps, but in a continuously updated display. This is useful for situations in which you need to watch the status of one or more processes or to see how they are using your system.

In addition, a header of useful uptime, load, CPU status, and memory information is displayed. By default, the process status output is generated with the most CPU-intensive processes at the top of the listing (and is named for the "top" processes). To format the screen, top top must understand how to control the terminal display. The type of terminal (or terminal window) in use is stored in the environment variable must understand how to control the terminal display. The type of terminal (or terminal window) in use is stored in the environment variable TERM TERM. If this variable is not set or contains an unknown terminal type, top top may not execute. may not execute.

Popular command-line options Dashes are optional in top top options: options: -b Run in batch mode. This is useful for sending output from top top to other programs or to a file. It executes the number of iterations specified with the to other programs or to a file. It executes the number of iterations specified with the -n -n option and terminates. This option is also useful if option and terminates. This option is also useful if top top cannot display on the terminal type you are using. cannot display on the terminal type you are using.

-d delay delay Specify the delay delay in seconds between screen updates. The default is five seconds. in seconds between screen updates. The default is five seconds.

-i Ignore idle processes, listing only the "interesting" ones taking system resources.

-n num num Display num num iterations and then exit, instead of running indefinitely. iterations and then exit, instead of running indefinitely.

-q Run with no delay. If the user is the superuser, run with highest possible priority. This option causes top top to update continuously and will probably consume any idle time your CPU had. Running to update continuously and will probably consume any idle time your CPU had. Running top -q top -q as superuser will seriously affect system performance and is not recommended. as superuser will seriously affect system performance and is not recommended.

-s Run in secure mode. Some of top top's interactive commands can be dangerous if running as the superuser. This option disables them.

Frequently used interactive options Once top top is running interactively, it can be given a number of commands via the keyboard to change its behavior. These commands are single-key commands, some of which cause is running interactively, it can be given a number of commands via the keyboard to change its behavior. These commands are single-key commands, some of which cause top top to prompt for input: to prompt for input: s.p.a.cebar Refresh the screen.

h Generate a help screen.

k Kill a process. You will be prompted for the PID of the process and the signal to send it. (The default signal is 15, SIGTERM SIGTERM.) See Terminating Processes Terminating Processes.

n Change the number of processes to show. You will be prompted to enter an integer number. The default is 0, which indicates that the screen should be filled.

q Quit the program.

r Change the priority of a process (renice). You will be prompted for the PID of the process and the value to nice it to (see nice nice and and renice renice in in Objective 6: Modify Process Execution Priorities Objective 6: Modify Process Execution Priorities). Entering a positive value causes a process to lose priority. If the superuser is running top top, a negative value may be entered, causing a process to get a higher than normal priority. This command is not available in secure mode.

s Change the delay in seconds between updates. You will be prompted for the delay value, which may include fractions of seconds (e.g., 0.5).

Example 1 Simply executing top top without options gives a full status display updated every five seconds: without options gives a full status display updated every five seconds: $top Use the q q command to quit. command to quit.

Example 2 To run top top with a faster refresh rate, use the interval option, specified here with a one-second refresh: with a faster refresh rate, use the interval option, specified here with a one-second refresh: $top-d1 Example 3 You may wish to use top top to log its output to a file. Use the to log its output to a file. Use the -b -b (batch) option for this purpose. In this batch example, the (batch) option for this purpose. In this batch example, the -i -i option eliminates idle processes, the option eliminates idle processes, the -n -n option, with its argument, indicates five iterations, and the option, with its argument, indicates five iterations, and the -d -d option indicates a one-second interval. Results will be redirected to option indicates a one-second interval. Results will be redirected to file1 file1. This command will take five seconds to execute and does not use the optional dashes: $topbi-n5-d1>file1 The single-key interactive commands can be used when top top is running interactively. For example, if you type the is running interactively. For example, if you type the h h command, command, top top displays a help screen. If you enter the displays a help screen. If you enter the n n command, command, top top prompts you for the number of lines you wish to display. prompts you for the number of lines you wish to display.

Using top top to change the to change the nice nice (priority modifier) value for a process is discussed in (priority modifier) value for a process is discussed in Objective 6: Modify Process Execution Priorities Objective 6: Modify Process Execution Priorities.

Name free Syntax free[options]

Description Display amount of free and used memory in the system.

Frequently used options -b Show memory usage in bytes.

-k Show memory usage in kilobytes.

-m Show memory usage in megabytes.

-t Display a line showing totals.

-s X X Continuous operation at X X second intervals. second intervals.

Example Display current memory usage in megabytes and display a total line: $freetm totalusedfreesharedbufferscached Mem:202318741490771089 -/+buffers/cache:7071316 Swap:40313513680 Total:605522253830 This tells me that I have 2,023 megabytes of system memory (2 gigabytes) and 4,031 megabytes (about 4 gigabytes) of swap s.p.a.ce. I'm currently using 1,874 megabytes of memory, leaving 149 free.

Name uptime Syntax uptime Description uptime gives a one-line display of the following information: the current time, how long the system has been running, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes. gives a one-line display of the following information: the current time, how long the system has been running, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes.

Examples $uptime 13:17:57up214days,2:52,4users,loadaverage:0.09,0.03,0.01 Load average on a Linux system is defined as the number of blocking processes in the run queue averaged over a certain time period. A blocking process is a process that is waiting on a resource to continue, usually the CPU, disk I/O, or network. Many processes waiting in the run queue will drive up the load average of your system. It's not uncommon to see a load average over 1; that just means for the designated time interval (1, 5 or 15 minutes) there was an average of at least one process waiting on resources in the run queue. This is usually indicative of a busy system and might not necessarily mean anything is amiss. However, high load averages will negatively affect system performance, so it's always a good idea to be aware of what is causing them. Here is the uptime output of a relatively busy web server: $uptime 1:20pmup3days15:49,1user,loadaverage:1.47,1.10,0.83

Name kill Syntax kill[-ssigspec|-sigspec][pids]

kill-l[signum]

Description In the first form, kill kill is used with an optional is used with an optional sigspec sigspec. This is a signal value, specified as either an integer or the signal name (such as SIGHUP SIGHUP, or simply HUP HUP). The sigspec sigspec is case-insensitive but is usually specified with uppercase letters. The is case-insensitive but is usually specified with uppercase letters. The bash bash built-in built-in kill kill is case-insensitive, both when using the is case-insensitive, both when using the -s -ssigspec and the and the -sigspec -sigspec forms, but the standalone forms, but the standalone kill kill is only case-insensitive in the is only case-insensitive in the -s -ssigspec form. For this reason, it is best to use uppercase signal names. You may use form. For this reason, it is best to use uppercase signal names. You may use -s -ssigspec or simply or simply - -sigspec to make up the signal value or name. If a to make up the signal value or name. If a sigspec sigspec is not given, then is not given, then SIGTERM SIGTERM (signal 15, "exit gracefully") is a.s.sumed. The (signal 15, "exit gracefully") is a.s.sumed. The sigspec sigspec is followed by one or more PIDS to which the signal is to be sent. In the second form with the is followed by one or more PIDS to which the signal is to be sent. In the second form with the -l -l option, option, kill kill lists the valid signal names. If lists the valid signal names. If signum signum (an integer) is present, only the signal name for that number will be displayed. (an integer) is present, only the signal name for that number will be displayed.

Examples This command displays the signal name SIGTERM SIGTERM, the name of signal 15, and the default when kill kill is used to signal processes: is used to signal processes: $kill-l15 TERM All of the following commands will send SIGTERM SIGTERM to the processes with PIDs 1000 and 1001: to the processes with PIDs 1000 and 1001: $kill10001001 $kill-1510001001 $kill-SIGTERM10001001 $kill-sigterm10001001 $kill-TERM10001001 $kill-s1510001001 $kill-sSIGTERM10001001 If those two processes are playing nicely on your system, they'll comply with the SIGTERM SIGTERM signal and terminate when they're ready (after they clean up whatever they're doing). Not all processes will comply, however. A process may be hung in such a way that it cannot respond, or it may have signal and terminate when they're ready (after they clean up whatever they're doing). Not all processes will comply, however. A process may be hung in such a way that it cannot respond, or it may have signal handling signal handling code written to trap the signal you're trying to send. To force a process to die, use the strongest code written to trap the signal you're trying to send. To force a process to die, use the strongest kill kill: $kill-910001001s $kill-KILL10001001 These equivalent commands send the KILL KILL signal to the process, which the process cannot ignore. The process will terminate immediately without closing files or performing any other cleanup. Because this may leave the program's data in an inconsistent state, using the signal to the process, which the process cannot ignore. The process will terminate immediately without closing files or performing any other cleanup. Because this may leave the program's data in an inconsistent state, using the KILL KILL signal should be a last resort. When a process is blocked waiting for I/O, such as trying to write to an unavailable NFS server or waiting for a tape device to complete rewinding, the signal should be a last resort. When a process is blocked waiting for I/O, such as trying to write to an unavailable NFS server or waiting for a tape device to complete rewinding, the KILL KILL signal may not work. See below. signal may not work. See below.

The httpd httpd daemon will respond to the daemon will respond to the HUP HUP signal by rereading its configuration files. If you've made changes and want signal by rereading its configuration files. If you've made changes and want httpd httpd to reconfigure itself, send it the to reconfigure itself, send it the HUP HUP signal: signal: $kill-HUP'cat/var/run/httpd.pid'

Many other daemons respond to SIGHUP SIGHUP this way. this way.

The back quotes are replaced by the sh.e.l.l with the contents of the file httpd.pid httpd.pid, which httpd httpd creates when it starts. creates when it starts.

Other programs allow you to send signals to processes without indicating their PID. killall killall will send a signal to all processes that match a given name, and will send a signal to all processes that match a given name, and killproc killproc will send a signal to all process that match a full pathname. will send a signal to all process that match a full pathname.

On the ExamNote that kill kill is used for sending all kinds of signals, not just termination signals. Also, be aware of the difference between the PID you intend to kill and the signal you wish to send it. Since they're both integers, they can sometimes be confused. is used for sending all kinds of signals, not just termination signals. Also, be aware of the difference between the PID you intend to kill and the signal you wish to send it. Since they're both integers, they can sometimes be confused.

Name bg Syntax bg[jobspec]

Description Place jobspec jobspec in the background, as if it had been started with in the background, as if it had been started with & &. If jobspec jobspec is not present, then the sh.e.l.l's notion of the is not present, then the sh.e.l.l's notion of the current job current job is used, as indicated by the plus sign ( is used, as indicated by the plus sign (+) in output from the jobs jobs command. Using this command on a job that is stopped will allow it to run in the background. command. Using this command on a job that is stopped will allow it to run in the background.

Name fg Syntax fg[jobspec]

Description This command places the specified job in the foreground, making it the current job. If jobspec jobspec is not present, the sh.e.l.l's notion of the current job is used. is not present, the sh.e.l.l's notion of the current job is used.

Name jobs Syntax jobs[options][jobspecs]

Description List the active jobs. The optional jobspecs jobspecs argument restricts output to information about those jobs. argument restricts output to information about those jobs.

Frequently used option -l Also list PIDs.

Name nohup Syntax nohup[options][command][args...]

Description Run a command immune to hangups, with output to a non-TTY terminal.

Example 1 Run the command /opt/bin/myscript.sh /opt/bin/myscript.sh in the background, with standard output and standard error redirected to in the background, with standard output and standard error redirected to nohup.out nohup.out: $nohup/opt/bin/myscript.sh& [1]12611On the ExamBe sure to know how to display background jobs and how to switch among them.

Objective 6: Modify Process Execution Priorities Part of Linux's flexibility is to let users and administrators prioritize process execution. This feature is handy when you have a high-load machine and want to make sure special processes (like yours!) get more rights to use system resources than others. It also is useful if you have a process that's gone haywire and you want to debug the problem prior to killing it. On the flip side, you can bury nonessential processes, giving them the lowest priority so they don't ever conflict with other processes.

Generally, on a day-to-day basis, you don't need to worry about execution priority, because the kernel handles it automatically. Each process's priority level is constantly and dynamically raised and lowered by the kernel according to a number of parameters, such as how much system time it has already consumed and its status (perhaps waiting for I/O; such processes are favored by the kernel). Linux gives you the ability to bias the kernel's priority algorithm, favoring certain processes over others.

The priority of a process can be determined by examining the PRI column in the results produced from issuing either the top top or or ps -l ps -l commands. The values displayed are relative; the higher the priority number, the more CPU time the kernel offers to the process. The kernel does this by managing a queue of processes. Those with high priority are given more time, and those with low priority are given less time. On a heavily loaded system, a process with a very low priority may appear stalled. commands. The values displayed are relative; the higher the priority number, the more CPU time the kernel offers to the process. The kernel does this by managing a queue of processes. Those with high priority are given more time, and those with low priority are given less time. On a heavily loaded system, a process with a very low priority may appear stalled.

nice One of the parameters used by the kernel to a.s.sign process priority is supplied by the user and is called a nice number nice number. The nice nice command command[1] is used to a.s.sign a priority number to the process. It is so named because it normally causes programs to execute with lower priority levels than their default. Thus, the process is being "nice" to other processes on the system by yielding CPU time. With this scheme, more "niceness" implies a lower priority, and less niceness implies a higher priority. is used to a.s.sign a priority number to the process. It is so named because it normally causes programs to execute with lower priority levels than their default. Thus, the process is being "nice" to other processes on the system by yielding CPU time. With this scheme, more "niceness" implies a lower priority, and less niceness implies a higher priority.

By default, user processes are created with a nice number nice number of zero. Positive numbers lower the priority relative to other processes, and negative numbers raise it. For example, if you have a long-running utility and don't want to impact interactive performance, a positive nice number will lower the job's priority and improve interactive performance. of zero. Positive numbers lower the priority relative to other processes, and negative numbers raise it. For example, if you have a long-running utility and don't want to impact interactive performance, a positive nice number will lower the job's priority and improve interactive performance.

Nice numbers range from 20 to +19. Any user can start a process with a positive nice number, but only the superuser (root) can lower a process's nice number and thus raise its priority. Remember, the lower the nice number, the higher the priority to the CPU.

[1] Some sh.e.l.ls, not including Some sh.e.l.ls, not including bash bash, have a built-in nice nice command. command.

Name nice Syntax nice[-nadjustment][command]

nice[-adjustment][command]

Description The nice nice command alters another process's nice number at start time. For normal users, command alters another process's nice number at start time. For normal users, adjustment adjustment is an integer from 1 to 19. If you're the superuser, the is an integer from 1 to 19. If you're the superuser, the adjustment adjustment range is from 20 to 19. If an range is from 20 to 19. If an adjustment adjustment number is not specified, the process's nice number defaults to 10. The number is not specified, the process's nice number defaults to 10. The command command consists of any command that you might enter on the command line, including all options, arguments, redirections, and the background character consists of any command that you might enter on the command line, including all options, arguments, redirections, and the background character & &.

If both adjustment adjustment and and command command are omitted, are omitted, nice nice displays the current scheduling priority, which is inherited. displays the current scheduling priority, which is inherited.

Example 1 The following command starts a program in the background with reduced priority, using the default nice number of 10: $nicesomecmd-opt1-opt2arg1arg2& Example 2 As superuser, you can start programs with elevated priority. These equivalent commands start the vi vi editor with a higher priority, which may be necessary for administrative purposes if the system is exceptionally slow: editor with a higher priority, which may be necessary for administrative purposes if the system is exceptionally slow: #nice--10vi/etc/hosts.deny #nice-n-10vi/etc/hosts.deny Note the double dash (--10) in the first form. The first dash indicates that an option follows, whereas the second dash indicates a negative number.

Be careful when using nice nice on interactive programs such as editors, word processors, or browsers. a.s.signing a program a positive nice number will most likely result in sluggish performance. Remember, the higher the positive number, the lower the resulting priority level. on interactive programs such as editors, word processors, or browsers. a.s.signing a program a positive nice number will most likely result in sluggish performance. Remember, the higher the positive number, the lower the resulting priority level.

Please click Like and leave more comments to support and keep us alive.

RECENTLY UPDATED MANGA

The Grand Secretary's Pampered Wife

The Grand Secretary's Pampered Wife

The Grand Secretary's Pampered Wife Chapter 574.1: JiaoJiao and Long Yi Author(s) : Pian Fang Fang, 偏方方, Folk Remedies, Home Remedy View : 244,011
My Rich Wife

My Rich Wife

My Rich Wife Chapter 2679: The Miracle Author(s) : Taibai And A Qin View : 1,540,323
Overgeared

Overgeared

Overgeared Chapter 2011 Author(s) : Park Saenal View : 12,414,320
Tondemo Skill de Isekai Hourou Meshi

Tondemo Skill de Isekai Hourou Meshi

Tondemo Skill de Isekai Hourou Meshi Chapter 602: Easy Bacon-Style Porkbelly Author(s) : 妖精壱号, Yosei Ichigo, Eguchi Ren, 江口連 View : 2,393,662

LPI Linux Certification in a Nutshell Part 9 summary

You're reading LPI Linux Certification in a Nutshell. This manga has been translated by Updating. Author(s): Adam Haeder. Already has 796 views.

It's great if you read and follow any novel on our website. We promise you that we'll bring you the latest, hottest novel everyday and FREE.

NovelOnlineFull.com is a most smartest website for reading manga online, it can automatic resize images to fit your pc screen, even on your mobile. Experience now by using your smartphone and access to NovelOnlineFull.com