By lanf, source: http://otn.racle.com/global/cn/pub/Articles/calish_system.html
Author: Sheryl Calish
Although the GUI desktop (such as KDE and GNOME) can help users use the Linux feature without the need for the functional knowledge of the command line interface, it is often necessary for more functionality and flexibility. Moreover, it is basically familiar with these commands to correctly automate certain functionality in the shell script. This article is a "fast tutorial" on Linux file commands, which is provided for users who just contact this operating system or just need to supplement this knowledge. It contains a concise overview of some more useful commands and guidance for their most powerful applications. The information contained below - combines some experiments - will enable you to easily grasp these basic commands. (Note: When involving a kernel combined with the Oracle Cluster File System (OCFS), the behavior of certain commands in these commands may be slightly different. In this case, Oracle provides an OCFS toolset, which The tool set can provide a better selection for file command applications.) Note that all examples included here are tested on SUSE Linux 8.0 Professional. Although there is no reason to believe that they will not work in other systems, but if you have problems, you should view your documentation for possible changes. Background concept allows us to review some basic knowledge before deep research specification. Files and commands are in the Linux / UNIX operating system, all things are treated as a file: hardware devices (including keyboards and terminals), directory, command itself, of course, there are files. This strange practice is actually the basis for Linux / UNIX's ability and flexibility. Most (almost all) command forms are as follows: command [option] [Source File (s)] [Target File] Get one of the most useful commands is those that provide help (especially those who learn Linux In the words). Two important sources of information in Linux are online reference manuals, or the Man page and whatis tool. You can use the Whatis command to access a MAN page that is unfamiliar command. $ Whats Echo To learn more about this command, you can use: $ man echo If you don't know the command required for a special task, you can use man -k (also known as Apropos) and a topic to generate possible The command. For example: $ man -k files A very useful but often ignored commands provide information about using Man itself: $ man man You can use spaceBar to browse any MAN page; UP Arrow will roll up the file up. To exit, type q,!, Or ctrl-z. User category Remember the name of the sentence "An example of all animals, but some animals are more equal than other animals"? In the Linux world, root users have everything. Root users can log in with another username SU (originated from "Superuser"). To perform tasks such as adding a new user, printer, or file system, you must log in as root user or switch to superuser with the subscriber password. System files (including system files for control initialization) are owned by the root user. Although ordinary users may be allowed to read them, they can leave the root user for the original cause of system security. Although the Bash Shell provides other shells, Bash (Bash Again Shell) is the default shell of Linux. It combines the characteristics of Bourne Shell with its same name and the characteristics of Korn, C and TCSH shells.
Bash's built-in command History defaults to the last 500 commands. You can view them by entering History at the command prompt. To retrieve a specific command, press UP Arrow or Down Arrow at the command prompt, or enter its number in the historical list, and add "!", For example: $! 49 You can also pass A command to execute this command in the distance of the project in the historical list: If there are 53 events in the historical list, the event number 51 will be executed. Like other shells in UNIX / Linux, BASH uses special environment variables to facilitate system management. For example: HOME, user main directory PATH, Linux is used to search for the executable image of the command you entered HISTSIZE, the number of historical events saved by the system except these reserved keywords, you can define your own environment. variable. For example, Oracle uses Oracle_Home (and some other variable), to make Oracle installations successfully, you must set these variables in your environment. The variable can be temporarily set at the prompt: $ HISTSIZE = 100, or in / etc / profile, the system range is permanently set, or local permanent settings in .profile. You can access the value of an environment variable through the echo command, and use a $ symbol to view this value. $ Echo $ HOME / HOME / Bluher can use the ENV command to view all current environment variables. Regular expressions and wildcards Many Linux commands use wildcards * and to match any number of characters or match any single characters respectively; the regular mode matching expression uses a period (.) To match any of the "Retine". character. In both cases, square brackets ([]) are used to match the character groups other than the "*" number. However, * is similar but different in all situations: Although it matches one or more characters in the shell, in the regular expression, it matches the zero or more examples of the above characters. Some commands (such as EGREP and AWK) use a set of broader special characters to match mode matching. The file processing command analyzes a file list ls command to see a list of files in any directory with execution permissions, which has many interesting options. For example: $ ls -liah * 22684 -rw-r - r - 1 Bluher Uses 952 DEC 28 18:43 .profile19942 -rw-r - r - 1 scalish users 30 Jan 3 20:00 Test2.out925 - RWXR-XR-X 1 SCALISH USERS 378 SEP 2 2002 Test.sh list list Shows 8 columns: column 1 indicates the inode of the file, because we use the -i option. The remaining columns are normal display through the -L option. Line 2 shows file type and file access. The number 3 shows the number of links, including the directory. The owners and group owners of the files are displayed in paragraphs 4 and 5. Here, owner "Bluher" belongs to group "users". Seating 6 shows the file size (in units of the unit, not the default byte, because we use -h option. Seventh column shows the date (it looks like three columns), including month, day and Year, and the day of the day. The file name is displayed in page 8. Use -A will enable the list in the list in the list of items (such as .profile).
Processing files can be moved (MV), replicated (CP) or delete (RM) files and directories. Use the -i option in wise to get a good idea. $ cp -i ls.out ls2.outcp: OverWrite `ls2.out '? mv command allows the -b option, which will make a backup copy before moving the file. RM and CP accept the powerful but dangerous -r option, which will be recursively executed on a directory and its file. $ RM -IR TESTRM: DESCEND INTO DIRECTORY `TEST '? Y can use MKDIR to create a directory, with RMDIR to delete the directory. However, since RMDir cannot be used to delete the contents of the file containing the file, it is usually more convenient to use the RM plus -R option. For security reasons, all files have all rights and protection. File Access Permissions (or file mode) contains the same 10 characters as previously mentioned: The first character indicates that the file type. The most common thing is - represents files, D represents a directory, and l represents links. The next 9 characters are access to three user categories: file owner (character 2-4), user group (5-7), and others (8-10), where R represents read rights, W represents write access , X indicates execution permissions on a file. Dash - If any of these nine locations appears, indicate that this operation is forbidden to use the category. You can use the chmod command to set access to the character symbol or binary mask. To use a binary mask, you must convert the characters of the three permissions groups into a binary format, then convert to an octal format: User category: Owner user group other characters Representation: RWX RX R - binary Representation: 111 101 100 octic : 7 5 4 Give the write permissions to the user group, you can use: ChMod G W Test.sh or chmod 774 test.sh with umask commands, in the /etc/init.dev file, or in. Local file permissions in the Profile file default settings. This command indicates that the number is subtracted with 777 to get the default permissions: $ umask 022 This will generate a default file permission 755 for all new files created by the user. You can use Chown to modify the ownership of the file: $ Chown Bluher Ls.out, Bluher is a new file owner. Similarly, group members will be modified as follows: $ ChGRP devgrp ls.out, DEVGRP is a new user group. LS does not provide which files are text, which files are binary information. To understand this information, you can use the file * command. The renaming file gives two popular ways to multiple names to use the link and alias commands. Alias can be used to re-a more convenient name for a longer command: $ alias ll = 'ls -l' $ ll pay attention to the use of single quotes, which makes BASH to pass the item to alias, not to estimate it . Alias can also be used as a longer path name abbreviation: $ alias jdev9i = / jderv9i / jderv / bin / jdev for more information on Alias and its reverse command UNALIAS, see "shell Builtin Commands" of Bash's Man page Sub portion. In the last example, an environment variable is defined to achieve the same result.
$ export jdev_home = / jdev9i / jdev / bin / jdev $ Echo $ jdev_home / jdev9i / jdev / bin / jdev $ jdev_home link allows several file names to reference a single source file, the format is as follows: ln [-s] fileyouwanttolinkto newname separate The ln command creates a hard link to the file, and use the -s option to create a symbolic link. Briefly, a hard link is hardly separated from the original file area (except for the inode of the two files). The symbolic link is easier to distinguish because they appear in a long file list, and use-> to indicate the source file, l indicate the file type. The commands that view and find file file filters are used to read file content and execute operations on file contents are sometimes referred to as 1Y filters. The SED and AWK commands are examples of two filters because they have their detailed discussions in the previous OTN articles, which will be slightly here. Commands such as Cat, More, and Less allow you to view the contents of a text file from the command line without calling the editor. CAT is an abbreviation of "concatenate", which will default to display the file content on the standard output (display). One of the most interesting options provided with CAT is the -n option, which displays the file content with the number output line. $ cat -n test.out1 this is a test. Because of all lines in the Cat in a single output file, you might prefer to use more and less, because they all output a screen content. Less is an enhanced version of more that allows you to enhance files with a key command from the VI text editor. For example, D forward is rolled forward, and B is turned backwards (if N is specified before D or B). The value of N-input becomes the default value of the subsequent D command. The MAN page utility uses LESS to display the contents of the instructions. Redirection and Pipe Redirection Allows the command output to redirect to the file, rather than standard output, or similarly, or redirect input. Returned Standard Symbol> Create a new file. >> Symbols Add to an existing file: $ more test2.outanother test. $ Cat test.out >> Test2.out $ cat test2.outanother test.this is a test. To file standard input can be used
The basic format is: grep [options] pattern [file ...] $ grep -r 'Subject' NSMAIL Ctrl-z will terminate the above or any other command. The most useful option of GREP may be -s. If you search the system file with any identity other than rooted users, an error message will be generated for each file you have no access. This command prohibits those messages. FGREP (also in grep -f call) only looks for a fixed string instead of GREP's regular expression. The EGREP receives a mode containing a larger range of special characters (such as "|", it indicates the condition OR operator). $ EGREP 'SUBJECT | MAILTO' * Find the GNU version of the file Find command is very powerful, flexible and more inclusive than the classic version existing on the UNIX system. It is very useful for tasks involving a directory structure, including finding and executing commands on a file. The basic format of the Find command is: $ FIND StartDirectory Options MatchCriteria [ActionOptions] If you know the name of the file, or even the name, you don't know what it is, you can do this: $ find.-name 'test * './test./jdevhome/mywork/empws/empbc4j/test is different from the classic UNIX system, do not need to add -print operation at the end in Linux, because if you do not specify other operational options, you will assume that this action will be assumed. One point (.) On the initial location of the directory will make the find starts searching in your working directory. Two points, .., start searching in the parent directory. You can start searching in any directory. Note that you can use wildcards as part of the search criteria (just enclose the entire project as long as single quotes). $ FIND.-name 'Test *' -print./test.out./test2.out Displays a series of files with the .Out extension: $ find / home -name '* .out' But remember, unless you are As a super user runs this command, you will have a lot of "permission denied" error messages. One of the most powerful search tools is to use with GREP - EXEC operations: $ find.-Name '* .html' -exec grep 'mailto: foo@yahoo.com' {} /; here, we let find command Start executing in the current directory, find an HTML file, *. HTML, and execute (-exec) grep commands on the current file, {}. When using the -EXEC operation, a semicolon is required; this is used to perform other operations when using the find command. Antilans / and quotes are required to ensure that these items are interpreted by Bash so that they are interpreted by the command rather than the shell. Master the Linux file command provides many useful commands in Linux and uses their powerful methods that cannot be explained here. In addition, there are usually many ways to complete many tasks. We have seen some of the most common and most inspirated Linux file commands. Mastering these foundations but Key tools will make your Linux to learn to go to the fast lane. With your man page, and the enthusiasm of the test, you now have enough information to start exploring the power of Linux file operations. In my next article, I will provide a similar description of the Linux system command.
We learned in the previous article that everything is regarded as a file in the Linux / UNIX world, including the system management command. For organizations, we discuss file commands in the first part of this series and will provide the most useful system diagnostics and maintenance commands in this article. For file commands, we discussed some fairly simple and intuitive management commands. Only the functions of other more complex commands are described in order to know these commands and their purposes when you need to use. This article does not involve detailed discussions on the basic principles behind each command, but we will discuss the most basic and most useful commands, which are used to monitor and manage printer services, file systems, disks, and processes. Many of the commands on superusers can be performed by regular users in their own files and processes. However, some commands, such as fdisk, need ROOT permissions to run. For your system integrity, it is recommended that you avoid logging in directly to the system directly. Instead, it is usually more suitable for regular user login, then executes the SUX command from X WINDOW to run the system management function. (SUX provides you with the X Window environment and root permissions.) When you log in with a root user, you will always know that you are in this state because your prompt is changed to "#". Super users can use sudo, selectively assign those permissions that are usually reserved for root users or other special users to a different regular user. The root user can define the actual and valid user and group identification NOD and GID to match the expected user's identity. This expected user can be (but not necessarily) users who are allowed to run the command. In other words, the super user can allow other users to perform a command, but it can also determine that any result files generated by the process should belong to the root user or any other user specified by the super user. SUDO permission is allocated, only users need to verify using their own password without requiring a root user password. General Commands From Technical, Uname, Diff, Date, Sort and UNIQ should be as file commands, but they explain them more meaningful because they are often used for system management of diagnostics and maintenance routines. Uname Uname provides regular system information. When specified -A option, display all available information: $ uname -alinux linux 2.4.18-4GB # 1 WED Mar 27 13:57:05 UTC 2002 I686 Unknown Here we see regular system information from left to right. Each information has its own option (in the parentheses below), it can be displayed separately: the operating system name is Linux (-s). This network node name is Linux (-N). The operating system release is 4.5.18-4GB (-R). Operating system version is # 1 WED Mar 27 13:57:05 UTC 2002 (-V). The machine type is I686 (-M). The processor type (-P) here is unknown. Similarly, Stty displays information about your terminal settings: $ stty -aspeed 38400 baud; rows 40; columns 103; line = 0; INTR = ^ C; quit = ^ /; ERASE = ^ ?; kill = ^ u; EOF = ^ D; EOL =; EOL2 =
; START = ^ Q;
STOP = ^ S; SUSP = ^ z; RPRNT = ^ r; werase = ^ W; LNEXT = ^ V; flush = ^ o; min = 1; time = 0;
-parenb -Parodd CS8-Hupcl-Cstopb Cread-Clocal -Crtscts -ignBrk -Brkint -Ignpar -Parmrk -inpck-Istrip -inlcr -Igncr ICRNL IXON -IXOFF -IUCLC-IXANY-IMAXBEL
Opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel NL0 CR0 TAB0 BS0 VT0 FF0
Isig Icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke
The second row and third lines show special characters and key sequences that will be called at the command line. For example, "^ z" is CNTRL-Z transmits a terminal rest in this system. Exit symbols are "^ /", cntrl- / send, and we can change it to "^ X", as shown below:
$ stty quit ^ x
In this case, you actually enter ^ symbols instead of the CNTRL key. This change only works in the current window. In order to make this change permanently take effect, you need to enter this statement in your .bashrc file.
DIFF and DATE. As the name suggests, DIFF compares two files. It returns those rows that lead to different files and returns some meaningless outputs about how to make the files.
$ DIFF TEST.out Test2.out
0A1
> Another test.
Here we were told here that the "Another Test." Is needed to add to Test.out to make it similar to Test2.out. The first character "0" is the line number to edit in Test.out; "a" indicates that the line should be added to Test.out to match the first row of Test2.out. If we need to change Test.out, the second character can be "c", and if we need to delete some content from Test.out, the second character is "D".
You may want to make a file similar to another file to provide a patch for some code. DIFF is often used as an analysis tool for verifying programs or scripts, such as whether the output of the SED script is expected.
The Date command can be used to display or set the date. If the user has a superuser authority, he or she can set the date by providing a digital string in the following command:
$ Date 0101010004
This command sets the date to 2004 (04) on January 1 (0101) (0100).
However, any user can display the date with the desired format. Note that a plus " " is required before the format sequence. If there is no expected output of this command, try to include it in single quotes:
$ DATE '% h% m% s'
204748
You can include space in the sequence, then you need to use double quotes:
$ DATE "% h% m% s"
20 47 51
There are more than 30 different format sequences listed on the date of the date, which can be combined as needed to get your last output format.
Date's output can also be used in scripts, such as:
$ DATE -D '2 Day'
Thu Jan 29 19:02:02 Est 2004
The -d option indicates that Date shows the time described in the string thereafter. In the above example, we asked to show the date from now on (January 27, 2004). We can also ask for three days ago, its commands are: $ DATE -D '-3 Day'
Sun jan 25 20:56:59 Est 2004
Another example of a Date is an additional string to which the additional string is output, providing a convenient method for generating a unique file name.
$ ls -l | cat> $ (DATE LS_% D% B% Y% H% M.out)
$ ls ls _ *. OUT
LS_04FEB041633.out
Here, we transfer the output of a long file list to CAT, which transfer our output to a file called LS_04FEB041609.out. Note We use a variable for the file name, indicated by the US dollar symbol "$". The "LS_" and ".out" are added to the date, the format is the day (% D) in the month, the local month name abbreviation (% B), the last two digits (% y), hour (% H) and minutes (% m) to produce this file name.
Sort and UNIQ. You can operate from the line from the pipe or the file specified from the command line. Unless otherwise specified, SORT operates on the first column of multiple columns. By default, digital columns are sorted in alphabetical columns unless the -n option is used.
The SORT column can be specified in two different formats. If you use the -k option, the position of the column starts from 1. You can also use the POS1 format, from the first column numbered numbered numbers. The following two commands produce the same output:
$ ls -l * .out | sort 5 -7
$ ls -l * .out | sort -k 6,8
-rw-r - r - 1 Bluher Users 375 DEC 5 2002 fdisk.out
-rw-r - r - 1 Bluher Uses 2447 DEC 28 20:15 ls.out
-rw-r - r - 1 Bluher Uses 590 Jan 4 21:24 Greps.out
-rw-r - r - 1 Bluher Users 78 Jan 4 21:25 SGREP.out
...
By default, the column separator of the sort command is a space and tab. You can specify additional separators using the -t SEP option, where SEP is the separator you specify. The default order of sort is from the highest to the highest, and the sequence can be reversed by the -R option.
SORT can be used in many different tasks. For example, it can be used to sort file output, or sort the output of the DU as we can see below. When using the -m option, sort merges the file and does not sort them. However, if you want to sort them, you should sort them before the file merge.
SORT is often used with the UNIQ command, deletes exactly the same line from the sorted file. The UNIQ command often follows the number of sort commands in the pipeline, and can also use the -c option to calculate the number of times the number of rows, or using the -d option, only the exact same line:
$ sort -m test.out test2_sort.out | uniq -c
1 annother test.
1 Testing Testing
THIS IS.
Here we merge two files Test.out and Test2_Sort.out. Then we use the -c option to transfer the output to UNIQ, so the last result is a list of alphabetical order, exactly the same row is deleted, and has a report on the frequency of each line. Printer control
In most cases, the use of the printer command is relatively clear. Send the job to the printer by specifying the file name after the LPR command. If the file name is not provided, the standard input is assumed. Using the LPQ command, you can get a status report on the job sent to the printer. When you specify a job number, LPRM removes the job from the row printer background print queue.
$ Lpr grep2.out $ lpqPrinter: lp @ linux 'lpdfilter drv = upp method = auto color = yes'Queue: 1 printable jobServer: pid 1929 activeUnspooler: pid 1930 activeStatus: waiting for subserver to exit at 21: 24: 14.637Rank Owner / ID Class Job Files Size Timeactive bluher @ linux 928 A 928 grep2.out 779 21: 24: 14done bluher A 877 (STDIN) 117258 13: 09: 53 $ lprm 928Printer lp @ linux: checking perms' cfA928linux.local'dequeued 'cfa928linux.local' here, when we send the job to the printer, we query its status. LPQ shows us that the number 877 has been completed, and the job we just sent is 928. We use the command LPRM 928 to remove the active job from the queue. Disk information Whether you are safeguarding your own system or supporting companies with many users, monitoring disk space is one of the more important responsibilities of system administrators. DU, DF and FDISK commands provide different views of available disk space. The du command provides an assessment of file space usage for each directory. By default, the measured unit is the number of blocks, and the size of the block is typically determined when you install your system. In the following example, the system is installed using a 1024-byte block. If there is no specified directory, the DU starts to calculate the current directory. -h option provides the size of the size of the easy-to-read form:
$ du -h Documents105k Documents / JJ573K Documents / JOHN682K Documents You can use the -a option to change the output, which indicates the number of blocks of DU display files and directories. Options - BLOCK-SIZE = SIZE indicates that the DU displays the output by the number of blocks specified by SIZE.
$ du --block-size = 512 Documents209 Documents / JJ1146 Documents / John1363 Documents In default, DUs are also recursively printed for each subdirectory. This action can be restricted by using the max-defth = n option, where n is equal to the maximum number of reported:
$ du --max-depth = 2. $ du --max-depth = 2 | sort -n4 ./.xemacs4./public_html105./documents/ian682./documents2420 ./jdevhome/system8350 ./ JDevhome / system9.0.3.103513483 ./jdevhome/mywork24252 ./jdevhome ... DU Report Directory and subdirectories Space usage, while DF reports disk space usage of installed file systems: $ dffilesystem 1k-blocks Used available use% Mounted on / dev / hda6 4195632 1983656 2211976 48% // dev / hda5 14607 3778 10075 28% / boot / dev / hda9 937372 494028 443344 53% / home / dev / hda8 6297248 3876880 2420368 62% / optshmfs 256220 0 256220 0% / dev / shm is here, DF reports the status of five file systems. Similar to DU, DF uses the -H option to provide human readable output:
$ DF -HFILESYSTEM SIZE Used Avail Use% MOUNTED ON / DEV / HDA6 4.0G 1.9G 2.1G 48% // DEV / HDA5 14M 3.7M 9.8M 28% / Boot / DEV / HDA9 915M 476M 440M 52% / Home / Dev / HDA8 6.0G 3.7G 2.3G 62% / OPTSHMFS 250M 0 250M 0% / dev / shm DF command also allows you to specify the size of the block with the -block-size = size option. The fdisk command is a partition table operation command for Linux. Unlike DU and DF, this command cannot be run when there is no root user permission. If the -l option is specified, it can only be used for the purpose of the report. It provides a complete view of your entire partition table, not just the extended Linux partition you have seen by DF:
# Fdisk -lDisk / dev / hda: 240 heads, 63 sectors, 1940 cylindersUnits = cylinders of 15120 * 512 bytesDevice Boot Start End Blocks Id System / dev / hda1 1 286 2162128 c Win95 FAT32 (LBA) / dev / hda2 * 288 1940 1249680 5 Extended / DEV / HDA5 288 289 15088 83 Linux / dev / hda6 290 844 4195768 83 Linux / dev / hda7 845 983 1050808 82 Linux swap / dev / hda8 984 1816 6297448 83 Linux / dev / hda9 1817 1940 937408 83 Linux Process Monitoring In a busy multi-user system, process monitoring is also an important responsibility for Linux system administrators. In this regard, PS and TOP are two most useful commands. The PS command provides a snapshot of the current running process. The following is the simplest form of PS:
$ PSPID TTY TIME CMD3884 PTS / 1 00:00:00 Bash3955 PTS / 2 00:00:00 More3956 PTS / 5 00:00:05 SQLPLUS PID is the identification number of the process. TTY is the terminal console belonging to the process. The Time column is the total CPU time used by the process. The CMD column lists the command line being executed. Use the PS with the -ef option to return a complete list of all the processes of all users in the system. If you transfer the results of this PS command to GREP, the result is easier to view. For example: $ ps -ef | grep oracleuid pid ppid c stime tty time cmdoracle 1633 1 0 13:58? 00: 00: 00: 1 0 13:58? 00: 00: 00 ora_dbw0_ora1racle 1637 1 0 13:58? 00 : 00: 01 ORA_LGWR_ORA1Oracle 1639 1 0 13:58? 00: 00: 02 ora_ckpt_ora1racle 1641 1 0 13:58? 00: 00: 02 ora_smon_ora1racle 1643 1 0 13:58? 00: 00: ORA_RECO_ORA1Oracle 1645 1 0 13:58 00: 00: 00 ora1racle 1647 1 0 13:58? 00: 01: 18 ora_qmn0_ora1racle 1649 1 0 13:58? 00: 00: 00 ora_d000_ora1 note, when you When the output of the PS is transmitted to the GREP command, the column header is not normally displayed when the PS command itself is used. For convenience of explanation, the title is above the output to clearly display its contact. Although the UID is typically an identifier of an index type, the user name is specified under the first column, and it is marked as a UID. PPID is the identification number of the parent process. For Oracle processes, the identification number here is 1 - it is the ID of the init process (parent process for all processes) because Oracle installed in this system is started as part of the login process. The column labeled CPU is used by the CPU to calculate the factor of performing priority. Stime refers to the startup time of the process. Question marks indicate that these processes are not part of any TTY because they are started by the system. The following is another example of the PS command with certain different options. Note that many columns are the same as columns when performing PS with -ef options:
$ ps auxuser pid% CPU% MEM VSZ RSS TTY Stat Start Time CommandBluh 4024 0.0 0.2 2240 1116 PTS / 1 S 20:59 0:00 Su Bluherbluh 4025 0.0 0.3 2856 1668 PTS / 1 S 20:59 0:00 Bashbluh 4051 0.0 0.2 2488 1504 PTS / 1 R 21:01 0:00 PS Auxbluh 4052 0.0 0.1 1636 600 PTS / 1 S 21:01 0:00 GREP Bluher In addition to providing important diagnostic information, the PS command is often used to find out of control process. PID. For example, one of your users enters a Cartesian join in the SQL * Plus session. You can do the following PS command to find its PID:
$ PS-EF | GREP Bluher ... Blure 4068 4064 0 21:14 PTS / 6 00:00:00 Lessbluher 4112 3945 0 21:28 PTS / 5 00:08:42 SQLPLUS ... Then you can use the following command Terminate it: $ KILL 4112 General User You can see all system processes, but they can only terminate their own processes. PS only provides you with a snapshot of the current process. To view the most active process instantly, you can use top. TOP provides process information in real time. It also has an interactive state, allowing the user to enter commands, such as the back of 5 or 10, etc. The result is that TOP displays 5 or 10 most active processes. Top continues to run until you press "Q" to exit TOP. The following is some of the top of top Show: 8: 14pm Up 51 min, 7 Uses, Load Average: 0.02, 0.03, 0.0596 Processes: 87 Sleeping, 2 Running, 0 Zombie, 7 Stoppedcpu State: 6.4% User, 3.5% System, 0.0% nice, 89.9% idleMem: 512440K av, 392288K used, 120152K free, 0K shrd, 55668K buffSwap: 1050800K av, 0K used, 1050800K free 236128K cachedPID USER PRI NI SIZE RSS SHARE STAT% CPU% MEM TIME COMMAND1289 root 18 0 78008 11M 1796 R 3.7 2.2 0:49 x1965 Blure 20 0 12244 11M 10456 s 1.9 2.3 0:01 kdeinit1986 Bluher 18 0 996 996 768 R 1.5 0.1 0:00 Top1803 Bluher 20 0 16960 16M 13508 S 0.9 3.3 0:03 kdeinit1804 Bluher 20 0 16964 16m 13508 s 0.9 3.3 0:03 kdeinit1800 Bluher 19 0 12260 11m 10076 s 0.1 2.3 0:04 kdeinit1 root 20 0 220 220 188 S 0.0 0.0 0:04 init ... Close In view, you should end this discussion with the shutdown command . Like many of the commands discussed in this article and the previous article, there is usually a replacement method in the form of a GUI to close your system. However, when you need to manually shut down, you can use the following command to close: $ Shutdown -h Now You can use the following command to manually restart the system: $ shutdown -r now Note that these two commands require a specified time. You can specify "now" or use -t option with time seconds. We discussed a lot of content in these two articles, but we absolutely unable to cover all content possible with Linux. There is still a lot of orders we have not discussed, and the command option we have not seen is more. However, here we want you to find at least to start managing the minimum tool required to manage Linux systems. About the author SHERYL CALISH is an Oracle developer specializing in the Blue Heron Consulting. She is also the Fund Chairman of Central Florida Oracle Uses Group and the sales chairman of IOUG Linux Sig.