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

What are the commands for Linux to improve productivity?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article introduces the relevant knowledge of "what are the commands for Linux to improve work efficiency". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1. Top command

The first command is top, which is a commonly used performance analysis tool under Linux, which can display the resource consumption of various processes in the system in real time, similar to the task manager under Windows.

Each top row represents a type of performance data:

Top: this line is a summary, 09:26:48 is the system time; up 169days is the run time; 1 user is the current number of logged-in users; load average is the load, and the next three numbers represent the load of 1 minute, 5 minutes, and 15 minutes, respectively. Load average data is the number of active processes checked every 5 seconds, and then the result is calculated.

Tasks task: total represents total number of processes; running represents running processes; sleeping represents dormant processes; stopped represents stopped processes; zombie represents zombie processes

CPU status: us is the percentage of CPU occupied by user space; sy is the percentage of kernel space occupied by CPU; ni is the percentage of CPU occupied by processes that have changed priorities; id is the percentage of idle CPU; wa is the percentage of CPU occupied by IO waiting; hi is the percentage of CPU occupied by hard interrupts; si is the percentage of CPU occupied by soft interrupts.

Mem memory: total is the total memory; used is the used memory; free is free memory; buffers is the amount of cached memory

Swap swap: total, used, free are the same as memory; cached is the total number of buffered swap areas

The following list shows the status monitoring of each process, each of which means as follows:

PID-process id

USER-process owner

PR-process priority

NI-nice value. Negative values indicate high priority and positive values indicate low priority VIRT-the total amount of virtual memory used by the process (in kb)

VIRT=SWAP+RESRES-the amount of physical memory used by the process that has not been swapped out, in kb. RES=CODE+DATA

SHR-shared memory size in kb

S-process status. D = uninterruptible sleep state R = run S = sleep T = track / stop Z = zombie process

% CPU-percentage of CPU time elapsed since last update

% MEM-percentage of physical memory used by the process

Total TIME+-the total CPU time used by the process, in 100 seconds

COMMAND-process name (command name / command line)

II. PS command

The second command is ps, and the commonly used command is ps aux or ps-ef, which is mainly used to view processes and is often used in conjunction with grep. The main usage scenario of this command is to check the process status or find the process number. Examples are as follows:

Ps aux | grep 'nginx' or ps-ef | grep' nginx'

3. Grep command

This command is mainly used to find strings in specified files or folders. The most common scenarios are used with commands such as ps, cat, tail, and so on. Examples are as follows:

Tail-f app.log | grep 'register'

4. Netstat command

This is a network-related command, and the main thing I use with this command is to find ports, such as:

Netstat-lntup | grep 80

In addition, netstat has many other features that you can search for if you are interested.

5. Find command

The find command is used to find a file in a specified directory, such as app.c in the\ home\ www directory on the server, you can look it up like this: find / home-name "* .c"

VI. Kill command

The kill command is a command used to kill a process. For example, to kill a process with a process number of 2198, the command is: kill 2198. You can also use kill-9 2198 to complete the process.

7. Tail command

We often use the tail command to monitor real-time logs, and sometimes with grep:

Tail-f app.log | grep login

This command looks at the input stream with the login identifier in the app.log log in the current directory in real time.

8. Cat command

The cat command is often used to view files, sometimes in conjunction with grep, as follows:

Cat app.log | grep 'login' | more

This command first opens the app.log log file in the current directory, then queries the log with login through grep, and finally displays it in pages with more.

If you want to display in reverse order, you can use the tac command, which has the same effect as cat, using the following:

Tac app.log | grep 'login' | more

This is the end of the content of "what are the commands for Linux to improve productivity?" Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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

Internet Technology

Wechat

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

12
Report