Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Good programmer Cloud Computing Learning Route sharing View process process

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Good Programmer Cloud Computing Learning Route Sharing View Process

To understand the process as follows:

· PID,PPID

·Current process status

·Memory allocation

CPU and actual time spent

User UID, who determines the privileges of the process

netstat -anptu View port

[root@tianyun ~]# yum clean all //Clear the old YUM database information

[root@tianyun ~]# yum makecache

static viewing process ps

[root@tianyun ~]# ps aux |less

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND

root 1 0.0 0.0 2164 648 ? Ss 08:47 0:00 init [5]

USER: The user running the process

PID: Process ID

%CPU: CPU utilization

%MEM: Memory Usage

VSZ: occupy virtual memory

RSS: Occupy real memory resident memory

TTY: Terminal on which the process runs

STAT: progress status man ps (/STATE)

rrun

S can interrupt sleep

D Uninterruptible sleep (usually IO)

T Stop the process

Z Zombie Process

X Dead process

START: Start time of the process

TIME: Total CPU time consumed by the process

COMMAND: process file, process name

[root@tianyun ~]# ps aux --sort %cpu |less

[root@tianyun ~]# ps aux --sort -%cpu |less

[root@tianyun ~]# ps aux --sort rss |less

[root@tianyun ~]# ps aux --sort -rss |less

[root@tianyun ~]# yum -y install httpd

[root@tianyun ~]# systemctl start httpd

[root@tianyun ~]# ps auxf |grep [h]ttpd

root 8310 0.0 0.1 10092 2912 ? Ss 14:19 0:00 /usr/sbin/httpd

apache 8311 0.0 0.0 10092 2060 ? S 14:19 0:00 \_ /usr/sbin/httpd

apache 8312 0.0 0.0 10092 2060 ? S 14:19 0:00 \_ /usr/sbin/httpd

apache 8313 0.0 0.0 10092 2060 ? S 14:19 0:00 \_ /usr/sbin/httpd

apache 8314 0.0 0.0 10092 2060 ? S 14:19 0:00 \_ /usr/sbin/httpd

apache 8315 0.0 0.0 10092 2060 ? S 14:19 0:00 \_ /usr/sbin/httpd

apache 8316 0.0 0.0 10092 2060 ? S 14:19 0:00 \_ /usr/sbin/httpd

apache 8318 0.0 0.0 10092 2060 ? S 14:19 0:00 \_ /usr/sbin/httpd

apache 8319 0.0 0.0 10092 2060 ? S 14:19 0:00 \_ /usr/sbin/httpd

[root@tianyun ~]# ps -ef

UID PID PPID C STIME TTY TIME CMD

root 1 0 0 08:47 ? 00:00:00 init [5]

//Custom Display Fields

[root@tianyun ~]# ps axo user,pid,ppid,%mem,command

[root@tianyun ~]# ps axo user,pid,ppid,%mem,command |grep httpd

root 8310 1 0.1 /usr/sbin/httpd

apache 8311 8310 0.0 /usr/sbin/httpd

apache 8312 8310 0.0 /usr/sbin/httpd

apache 8313 8310 0.0 /usr/sbin/httpd

apache 8314 8310 0.0 /usr/sbin/httpd

apache 8315 8310 0.0 /usr/sbin/httpd

apache 8316 8310 0.0 /usr/sbin/httpd

apache 8318 8310 0.0 /usr/sbin/httpd

apache 8319 8310 0.0 /usr/sbin/httpd

root 9236 6798 0.0 grep httpd

[root@tianyun ~]# ps axo user,pid,ppid,%mem,%cpu,command --sort -%cpu |less

//View PID of specified process

[yang@iZm5eiwihahzq6ds23gbf6Z ~]$ cat /run/sshd.pid

830

[root@tianyun ~]# ps aux |grep sshd

root 10180 0.0 0.0 7224 1024 ? Ss 16:00 0:00 /usr/sbin/sshd

[root@tianyun ~]# pgrep -l sshd

10180 sshd

[root@tianyun ~]# pgrep sshd

10180

[root@tianyun ~]# pidof sshd

10180

//View the process tree

[root@tianyun ~]# pstree

Dynamic View Process top

[root@tianyun ~]# top

[root@tianyun ~]# top -d 1

[root@tianyun ~]# top -d 1 -p 10126 View dynamic information about the specified process

[root@tianyun ~]# top -d 1 -p 10126,1

[root@tianyun ~]# top -d 1 -u apache View processes for a specified user

top -d 1 -u sshd

[root@tianyun ~]# top -d 1 -b -n 2 > top.txt Write 2 top messages to a file

Part I: Overall System Statistics

top - 14:15:04 up 47 min, 2 users, load average: 0.25, 0.18, 0.12

Tasks: 235 total, 1 running, 234 sleeping, 0 stopped, 0 zombie

Cpu(s): 8.9%us, 1.0%sy, 0.0%ni, 90.1%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st

Mem: 7944064k total, 746164k used, 7197900k free, 35724k buffers

Swap: 1048568k total, 0k used, 1048568k free, 261492k cached

load average: 0.86, 0.56, 0.78 CPU load average for the last 1 min, 5 min, 15 min

Part II: Process information

command

h|? help

M Sorted by memory usage

P Sorted by CPU usage

N sorted by PID size

R reverses the sort

f Custom Display Fields

1 shows all CPU loads

< 向前 >

backward

z color

W Save top environment settings ~/.toprc

netstat

netstat is used to view the current system network status information, including ports, connections, etc., commonly used as follows:

netstat -atunlp, the parameters have the following meanings:

-t : Indicates TCP port is displayed

-u : Indicates UDP port is displayed

-l : Show only listening sockets (sockets with LISTEN status)

-p : Displays the process identifier and program name, each socket/port belongs to a program

-n : No DNS resolution

-a Displays all connected ports· 1

This command is usually used in conjunction with grep, such as looking for port 22, using netstat -tunlp| grep 22 or simply netstat -an| grep 22 is OK, check other ports similar, of course, you can also find through the port status that is netstat -anp| grep TIME_WAIT, i.e. only entries containing the TIME_WAIT string will be displayed

lsof

The function of lsof is to list the open files of the current system (list open files), but you can also view the connection status of the port through the-i parameter, -i followed by the colon port can view the specified port information, directly-i is all the currently open ports of the system

lsof -i:22 #View port 22 connection, default is sshd port

Beijing---------------------------------------------------->> Guangzhou

server1 192.168.1.2 10.10.10.2

server2 192.168.1.3 10.10.10.3

1 cut service

2 System level: modify DNS network card configuration file routing

root

cisco -switch-01 port

cisco -switch-02 port

change

IP address

10.10.10.2 --------------------------→ 192.168.2.3

ping 192.168.2.3--> Not available to continue

ssh 10.10.10.2

Modify NIC configuration file/IP address/----192.168.2.3/---> Routing---Off

systemctl restart network--->xshell XXX dropped---→ vlan id of switch port--->

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report