Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Linux \ 10 important Linux ps command combat     - Everyone should know something about TCP (Linux)

- Debian 7.8 system installation and configuration process (Linux)

- Ubuntu15 core CLR (Server)

- Ubuntu 15.10 How to install TeamViewer 11 (Linux)

- Ubuntu users to install voice switch instructs the applet (Linux)

- Linux find and xargs (Linux)

- RAID configuration and management under linux (Server)

- Linux uses the SMTP proxy to send mail (Linux)

- Linux System Getting Started Learning: Repair fatal error openssl aes h no such file or directory (Linux)

- Oracle Database Delete Delete million or more common method of heap table data (Database)

- Use Ansible to bulk manage remote servers (Server)

- Puppet centralized configuration management system (Server)

- Ubuntu cut screen method (Linux)

- Linux 6 install Oracle 11g (64bit) (Database)

- Ubuntu 14.04 Install WordPress on Nginx (Server)

- Why everybody ought to know LLVM (Linux)

- Using Python and OpenCV detecting image barcode (Programming)

- Linux --- process handle limit summary (Linux)

- Xshell key authentication mechanism using a remote login Linux (Linux)

- How to add a new hard disk without restarting the CentOS 7 / RHEL 7 virtual machine (Linux)

  10 important Linux ps command combat
  Add Date : 2017-08-31      
  Linux as a Unix-derived operating system, Linux has built-in view of the current process tool ps. This tool can be used in the command line.

What is the PS command

See the man page it can be seen, ps command can give a snapshot of the current processes in the system. It can capture system process status in an event. If you want to see the updated status, you can use the top command.

ps command supports syntax used in three of

UNIX-style options can be combined, and there must be options before "-" hyphen
BSD-style options can be combined, but not before there is an option "-" hyphen
GNU-style long options, there are two options before "-" hyphen
We can mix these types of style, but a conflict may occur. As used herein, UNIX-style ps command. There is more use of the ps command in everyday life examples.

1. execute ps command with no arguments

This is a basic ps use. Execute this command in the console and see the results.

The results show four default message.

PID: running command (CMD) process ID
TTY: position command is running (terminal)
TIME: running the command of CPU processing time
CMD: Command run by this process
This information is not sorted in the display.

2. Display all the current process

Use -a parameter. -a representative of all. At the same time plus x parameter will show no controlling terminal.

$ Ps -ax
The results of this command may be very long. For ease of viewing, can be combined with less command and pipes to use.

$ Ps -ax | less

3. The user filtering process

In the need for specific user processes, we can use the -u parameter. For example, we want to view the user 'pungki' process can use the following command:

$ Ps -u pungki

4. cpu and memory usage to the filtering process

Maybe you want to put the results in accordance with the CPU or memory usage to filter, so you find out which process is using your resources. To do this, we can use the aux parameter to display comprehensive information:

$ Ps -aux | less

When the result of a long time, we can use the command to filter pipes and less.

The default result set is not sorted. You can be sorted by --sort command.

According to CPU usage in ascending order

$ Ps -aux --sort -pcpu | less

According to an ascending sort memory usage

$ Ps -aux --sort -pmem | less

We also can combine them into a command and displays the first 10 results through the pipeline:

$ Ps -aux --sort -pcpu, + pmem | head -n 10
5. Through the process name and PID filter

Use the -C parameter, followed by the name of the process you are looking for. For example, want to display a message named getty process, you can use the following command:

$ Ps -C getty

If you want to see more detail, we can see a list of information formatted using the -f parameter:

$ Ps -f -C getty

6. The thread to the filtering process

If we want to know the thread-specific process, you can use the -L argument, followed by a particular PID.

$ Ps -L 1213

7. The tree display process

Sometimes we want to show the process tree, you can use -axjf parameters.

$ Ps -axjf

Or you can use another command.

$ Pstree

8. Display Security Information

If you want to see who is now logged into your server. You can use the ps command with the parameters:

$ Ps -eo pid, user, args
Parameter -e show all processes information, -o parameter control output. Pid, User and Args parameter display PID, the user runs the application and the application.

Keywords can be used in conjunction with the -e parameter is args, cmd, comm, command, fname, ucmd, ucomm, lstart, bsdstart and start.

9. The process of formatting output root user (real or effective UID) is created

When the system administrator wants to see the process run by the root user and other relevant information about this process, you can use the following command:

$ Ps -U root -u root u
-U Parameter by real user ID (RUID) screening process, it will choose the real user name or ID from the user list. That is the real user of the process of the actual creation of the user.

-u parameter is used to screen the effective user ID (EUID).

U parameter is used to determine the final format for output to the user by the User, PID,% CPU,% MEM, VSZ, RSS, TTY, STAT, START, TIME and COMMAND these columns.

Here is the output of the above command:

10. Use the PS real-time monitoring process status

ps command will display the current process status of your system, but this result is static.

When there is a case, we need something like the CPU and memory usage screening process mentioned above, the fourth point, and we hope that the results can be refreshed once per second. For this reason, we can watch the ps command and the command together.

$ Watch -n 1'ps -aux --sort -pmem, -pcpu '

If the output is too long, we can limit it, such as before 20, we can use the head command to do.

$ Watch -n 1'ps -aux --sort -pmem, -pcpu | head 20 '

Here dynamic view is not as top or htop command. But using ps field advantage is that you can customize the display, you can choose what you want to see the field.

For example, if you just look at the name 'pungki' user, you can use the following command:

$ Watch -n 1'ps -aux -U pungki u --sort -pmem, -pcpu | head 20 '

in conclusion

You may use the ps command will be a day to monitor your Linux system. But in fact, you can generate a variety of reports you need via parameters ps command.

Another advantage is the ps command ps a variety of Linux systems are installed by default, so you just used on the line.

Do not forget by man ps to see more parameters. (LCTT Annotation: As the ps command ancient and important, so it is in different parameters of UNIX, BSD, Linux and other systems are not the same, so if you are not using Linux system, please consult your documentation for specific parameters available. )
- Using open source software to build XWiki Wiki system installed within the company (Linux)
- Nginx Beginner Guide (Server)
- Installation under Linux Mint system guidelines for Gtk (Linux)
- How to Install Sticky Notes on Ubuntu and Derivatives (Linux)
- Profile Linux users login shell and login to read (Linux)
- Simple and fast sorting (Programming)
- Talk about the Linux ABI compatibility Application (Linux)
- To install Internet security firewall Raiders (Linux)
- OpenGL Superb Learning Notes - Fragment Shader (Programming)
- Ubuntu How to install screen recording tool Simple Screen Recorder 0.3.1 (Linux)
- Linux use glibc2 library and crypt () function to generate the user password (Programming)
- Linux system Iptables Firewall User Manual (Linux)
- MySQL multi-master multi-cluster deployment uses alive Galera (Database)
- Oracle 11g partition maintenance (two) - Coalescing Partitions (Database)
- How to disable UEFI to install Linux on Win8 (Linux)
- RAID configuration and management under linux (Server)
- CentOS7 yum install third-party source EPEL (Linux)
- Android in the coordinate system and a method to obtain the coordinates (Programming)
- Linux Fundamentals of the memory management mechanism (Linux)
- redis main building and disaster recovery from a cluster deployment (Database)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.